在每个.py文件前加入如下代码: # -*- coding: utf-8 -*- 也可以指定其他编码格式 实例演示: # -*- coding: utf-8 -*- a='测试用汉字输出' print a 输出结果为 >>> 测试用汉字输出