Selenium+Python报错处理ascii


    1.
config = configparser.ConfigParser()
file_path = os.path.dirname(os.path.abspath('.')) + "/config/config.ini"
config.read(file_path)

在运行的时候,老提示第三行报错:UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe9 in position 327: ordinal not in range(128)
这是由于Python的编码格式的错误,只需要指定为统一的‘utf-8’即可。

config = configparser.ConfigParser()
file_path = os.path.dirname(os.path.abspath('.')) + "/config/config.ini"
config.read(file_path, 'utf-8')

转载自:https://blog.csdn.net/u014259820/article/details/81157423

You may also like...