Life is short, you need Python

摘要: # sort.py # -*- coding: gbk -*# 这个类用来演示如何对自定义对象进行排序 class Sortobj: a = 0 b = '' def __init__(self, a, b): self.a = a self.b = b def printab(self): print self.a, self.b # 演示对字符串列表进行排序 samplelist_str = ['blue','allen','sophia','keen'] print samplelist_str sample 阅读全文
posted @ 2011-04-27 17:26 runfox545 阅读(726) 评论(0) 推荐(0)
摘要: 若python文件中出现中文字符,运行时会出现如下错误SyntaxError: Non-ASCII character '\xd5' in file sort.py on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details可以在python的文件开始处加入下面声明即可fix这个error# -*- coding: gbk -* 阅读全文
posted @ 2011-04-27 17:25 runfox545 阅读(2446) 评论(0) 推荐(0)
白月黑羽 Python教程 白月黑羽Python