Python输出不了中文怎么解决

440次阅读
没有评论

Python输出不了中文怎么解决

在文件头加上#encoding:utf-8即可。

# encoding: utf-8
print 'helloworld'
print u"学习"
print (unicode("学习", encoding="utf-8"))

shell输出: 

helloworld
学习
学习

还可以用#-*- coding: UTF-8 -*- 来指定。

神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:wuyou2021-07-03发表,共计169字。
新手QQ群:570568346,欢迎进群讨论 Python51学习