pycharm里面,提示文件编码是UTF-8时提示错误:
UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xad in position 115: illegal multibyte sequence
当文件编码是gbk时提示错误:
SyntaxError: Non-UTF-8 code starting with ‘\xb1’ in file C:/xx/xx.py on line 10, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
且提示文件中出错的语句是:
pytest.main([‘test_yamlLogin.py’, ‘-s’, ‘–alluredir’, ‘…/report/tmp’])
解决方法是将主文件夹下的pytest.ini中的中文注释去掉,就没有报编码错误了