Python3 下打印 utf-8 字符串出现 UnicodeEncodeError 错误
来源:互联网 发布:华为手机不root修改mac 编辑:程序博客网 时间:2024/05/22 12:38
python3 如果要输出utf-8,需要通过以下代码将ANSI_X3.4-1968改为utf-8
import sysimport iosys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
然后再次检验stdout是否为utf-8
>>> sys.stdout<_io.TextIOWrapper name='' encoding='utf-8'>
之后就可以愉快地print了
转载声明:https://www.binss.me/blog/solve-problem-of-python3-raise-unicodeencodeerror-when-print-utf8-string/
http://lab.knightstyle.info/%E7%A7%81%E3%81%8Cpython3%E3%81%A7unicodeencodeerror%E3%81%AA%E3%81%AE%E3%81%AF%E3%81%A9%E3%81%86%E8%80%83%E3%81%88%E3%81%A6%E3%82%82%E3%83%87%E3%83%95%E3%82%A9%E3%83%AB%E3%83%88%E6%96%87%E5%AD%97/
阅读全文
0 0
- Python3 下打印 utf-8 字符串出现 UnicodeEncodeError 错误
- 解决Python3下打印utf-8字符串出现UnicodeEncodeError的问题
- 执行pip install 出现编码错误,UnicodeEncodeError:.....
- 解决WIN7下Sublime运行python代码出现的UnicodeEncodeError错误
- Windows下打印utf-8文件
- Python下UnicodeEncodeError编码错误的解决
- Python3 UnicodeEncodeError 问题解决
- python笔记 爬虫经常出现的错误UnicodeEncodeError
- pip install 出现报UnicodeEncodeError错误的问题
- windows下打印图片出现explorer.exe错误的问题?
- windows下utf-8转为unicode并打印输出
- xml文档使用utf-8编码中文出现错误
- maven打包出现的utf-8编码错误的解决
- maven打包出现的utf-8编码错误的解决
- python3.5 爬虫错误: UnicodeEncodeError: 'ascii' codec can't encode characters
- python3错误——UnicodeEncodeError: 'latin-1' codec can't encode character...
- 暴力补坑:win10+tensorflow+mnist+python3.6导入mnist数据错误:UnicodeEncodeError
- python3中split分割字符串出现错误 TypeError‘str’ does not support the buffer interface
- C++之include<iostream>与include<iostream.h>
- 以太网自动协商原理
- android中对于非属性动画的整理
- Linux JDK安装与配置
- Vue.js学习笔记
- Python3 下打印 utf-8 字符串出现 UnicodeEncodeError 错误
- 奇淫技巧____给图片添加水印(文字,图片)
- arm上安装jdk
- 扩展RBAC用户角色权限设计方案
- 限制文本行数
- .net core 文件上传
- 在智能监控领域 特征识别正在追赶“刷脸”技术
- 打造一个高性能混合Hybrid App
- Gradle project sync failed. please fix your project and try again