首页 > 文章列表 > Python输出不了中文怎么解决

Python输出不了中文怎么解决

Python 中文 输出
433 2022-08-07

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

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

shell输出: 

helloworld
学习
学习

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