'sys.flags' object has no attribute 'utf8_mode'

python运行程序时报以下错误,请问如何解决?

AttributeError: 'sys.flags' object has no attribute 'utf8_mode'

请参照下面的用法。如果题主的用法没有问题,那就要怀疑是否存在命名空间污染问题了,比如,自定义了sys,或者覆盖了sys的flags等。

>>> import sys
>>> sys.flags
sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0, dev_mode=False, utf8_mode=0)
>>> sys.flags.utf8_mode
0