用RawConfigParser代替ConfigParser,避免配置的cookies中的特殊字符

This commit is contained in:
g1879 2020-12-04 18:04:15 +08:00
parent 99fc7d650a
commit 95beaaa7e6

View File

@ -5,7 +5,7 @@
@Contact : g1879@qq.com @Contact : g1879@qq.com
@File : config.py @File : config.py
""" """
from configparser import ConfigParser, NoSectionError, NoOptionError from configparser import RawConfigParser, NoSectionError, NoOptionError
from http.cookiejar import Cookie from http.cookiejar import Cookie
from pathlib import Path from pathlib import Path
from typing import Any, Union from typing import Any, Union
@ -23,7 +23,7 @@ class OptionsManager(object):
:param path: ini文件的路径默认读取模块文件夹下的 :param path: ini文件的路径默认读取模块文件夹下的
""" """
self.ini_path = path or str(Path(__file__).parent / 'configs.ini') self.ini_path = path or str(Path(__file__).parent / 'configs.ini')
self._conf = ConfigParser() self._conf = RawConfigParser()
self._conf.read(self.ini_path, encoding='utf-8') self._conf.read(self.ini_path, encoding='utf-8')
self._paths = None self._paths = None