vim编辑python编码问题
时间:2011-08-11
来源:互联网
Python code
在vim中设置 set fileencoding=cp936 可以正常运行
但设成 fileencoding=utf-8运行时路径为乱码报错
cmd.exe /c python 2.py
Traceback (most recent call last):
File "2.py", line 2, in <module>
inFile = open(r'f:\make\娴嬭瘯\1.txt','r')
IOError: [Errno 2] No such file or directory: 'f:\\make\\\xe6\xb5\x8b\xe8\xaf\x9
5\\1.txt'
shell returned 1
Hit any key to close this window...
大家知道怎么回事吗?
# -*-coding:utf-8-*- inFile = open(r'f:\make\测试\1.txt','r') for line in inFile: print line
在vim中设置 set fileencoding=cp936 可以正常运行
但设成 fileencoding=utf-8运行时路径为乱码报错
cmd.exe /c python 2.py
Traceback (most recent call last):
File "2.py", line 2, in <module>
inFile = open(r'f:\make\娴嬭瘯\1.txt','r')
IOError: [Errno 2] No such file or directory: 'f:\\make\\\xe6\xb5\x8b\xe8\xaf\x9
5\\1.txt'
shell returned 1
Hit any key to close this window...
大家知道怎么回事吗?
作者: kithon 发布时间: 2011-08-11
Python code
试试
# -*-coding:utf-8-*- inFile = open(r'f:\make\测试\1.txt'.decode('utf-8'), 'r') for line in inFile: print line
试试
作者: Waistcoat23 发布时间: 2011-08-11
open识别不了编码,这样,inFile = open(ur'f:\测试\1.txt', 'r');
或者象LS一样解码
或者象LS一样解码
作者: I_NBFA 发布时间: 2011-08-11
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28