DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Python脚本文件中使用中文


Python做图形用户界面(GUI)开发时经常要在界面上显示中文,需要做如下处理(详见[1]和[2]2.3节):

  1. 在py文件的首行写上:# -- coding:utf-8 --

  2. 保存py文件时要存为utf-8格式文件。

[1] Python2.6 Documentation: The Python Language Reference: 2.1.4 Encoding declarations

[2] 孙广磊,征服Python—语言基础与典型应用,北京:人民邮电出版社,2007



Published

Jan 10, 2010

Last Updated

Jan 10, 2010

Category

Tech

Tags

  • 编码 6
  • Python 136
  • 中文 5

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor