首页 > 编程语言 > 详细

关于Python万恶的中文乱码和找不到问题

时间:2018-07-13 11:59:43      阅读:128      评论:0      收藏:0      [点我收藏+]
rootDir = os.path.join(CASE_PATH, "系统", "基础", "管理")
print rootDir
print(chardet.detect(rootDir))
print os.path.exists(rootDir)
unicode(rootDir, "utf-8")
print rootDir
print(chardet.detect(rootDir))
print os.path.exists(unicode(rootDir, "utf-8"))

E:\ABS\TestCase\系统\基础\管理

{‘confidence‘: 0.99, ‘language‘: ‘‘, ‘encoding‘: ‘utf-8‘}

False

E:\ABS\TestCase\系统\基础\管理

{‘confidence‘: 0.99, ‘language‘: ‘‘, ‘encoding‘: ‘utf-8‘}

True



网上各种回答乱入:

1.python默认安装的时候编码是ASCII

2.python内部执行程序时传递时是UNICODE

3.python内存中中文变现为UNNICODE


解决方法如上,暂时还在凌乱,后续再看吧


又报错打印出来路径变成16进制了

解决:rootDir.decode(‘utf-8‘).encode(‘utf-8‘)

关于Python万恶的中文乱码和找不到问题

原文:https://www.cnblogs.com/mariahcat/p/9304098.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!