Python3.3 print readline 乱码
来源:互联网 发布:弹珠枪在淘宝上怎么搜 编辑:程序博客网 时间:2024/05/18 03:13
os zsh vim 随意写了几行文本,中英数字符号混排,
然后 python,open,readline,结果 print 后中文乱码
因为 PHP 的经验一旦乱码首先想到的是编码的问题
文本应于归于数据源,即使有问题,也不追究,
故从其它环节入手.
首先
在 python 脚本里加入#coding:utf-8,不管用,
其次就是读取内容的转码,于是encode 不行就 decode
尝试多次之后发现依然不行,那就再改编码,既然不是 utf8,
那就改为 gbk再 encode,decode;终于
print(line.decode("gbk"))
尝试后,输出终于还原庐山真面目了,看到了文件内容的真实面目.
0 0
- Python3.3 print readline 乱码
- python3.3中的print()
- python3 出现print输出的中文乱码问题解决
- Python3.3 print函数用法,print 格式化输出
- Python3.3 print函数用法,print 格式化输出
- Python3.3 print函数用法,print 格式化输出
- BufferedReader.readLine() 日文乱码
- Python3--Print用法
- python3 print & DataFrame 170424
- Python3.X中的print
- python2的print和python3的print()
- 调用readLine的乱码问题
- ubuntu12.04 为python3.3安装readline模块 以及 tab键命令补全
- Python3.2 --- Print函数用法
- python3中print在一行
- Python3.x --- Print函数用法
- Python3.2 --- Print函数用法
- Python3.2 --- Print函数用法
- 要多动脑子,要追求效率
- HDU 2222 - Keywords Search (AC自动机)
- json-cpp 库使用
- query显示与隐藏实例
- POJ 1947 Rebuilding Roads(动态规划-树形DP)
- Python3.3 print readline 乱码
- POJ 3259--Wormholes(求负环)
- Jackson解析首字母大写的json字符串
- Android开发图形处理创建一个图形的拷贝
- XML笔记
- kmp算法--求字符串子串--《数据结构》严蔚敏
- 网络拓扑距离的高效KNN查询 (中期总结)
- CountDownLatch使用说明
- HDU 4906 Our happy ending 状压DP