python 代码中的问题 [ configparser.InterpolationSyntaxError: '%' 必须后跟 '%' 或 '(',found: '%' ] 使用 python 3.7.3 和 appium

Sun*_*nny 2 python appium python-3.7

以下终端日志供您参考

Traceback (most recent call last):
  File "src/Utilities_test/test_cases_csv.py", line 39, in <module>
    report_status = email_reporter(html_report_dir.split('/', 1)[-1])
  File "src/Utilities_support/report_email.py", line 27, in email_reporter for item in conf_data.items(conf): 
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 857, in items
    return [(option, value_getter(option)) for option in d.keys()]
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 857, in <listcomp>
    return [(option, value_getter(option)) for option in d.keys()]
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 854, in <lambda>
    section, option, d[option], d)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 394, in before_get
    self._interpolate_some(parser, option, L, value, section, defaults, 1)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 444, in _interpolate_some
    "found: %r" % (rest,))
configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: '%'
Run Code Online (Sandbox Code Playgroud)

小智 5

configparser 很可能正在读取字符串中的文字“%”符号。'%' 符号用于字符串插值(替换)。如果您想要一个文字“%”,可以用另一个“%”对其进行转义。例如,使用 '100%%' 来表示 configparser 读取的配置变量中的 '100%'。