- python3中UnicodeEncodeError: 'asc
- python3 UnicodeEncodeError: 'asc
- Python3 中使用cx_oracle模块执行sql报错 Un
- Python3中UnicodeEncodeError: 'gbk
- Python3中遇到UnicodeEncodeError: 'a
- python3运行提示UnicodeEncodeError: &
- Python3 UnicodeEncodeError
- python3 UnicodeDecodeError: 'asc
- python3 UnicodeEncodeError: '
- Python3 UnicodeEncodeError解决
python3下print下面字符报了错误。
>>> print('\u00bb')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character '\xbb' in position 0: ordinal not in range(128)
怀疑到了print方法,网上找到2个解决方案:
1.设置标准输出的编码
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf8')
2.修改系统设置的编码
如果安装系统为中文系统,则修改【LANG=“zh_CN.UTF-8”】
如果安装系统为英文系统,则修改【LANG=“en_US.UTF-8”】保存文件。
网友评论