Life is short, you need Python

上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 50 下一页
摘要: sina微博http://t.sina.com.cn/1941893380没办法,被逼的!! 阅读全文
posted @ 2011-04-28 11:16 runfox545 阅读(737) 评论(0) 推荐(0)
摘要: 在需要在字符中使用特殊字符时,python用反斜杠(\)转义字符。如下表:原始字符串有时我们并不想让转义字符生效,我们只想显示字符串原来的意思,这就要用r和R来定义原始字符串。如:print r'\t\r'实际输出为“\t\r”。转义字符描述\(在行尾时)续行符\\反斜杠符号\'单引号\"双引号\a响铃\b退格(Backspace)\e转义\000空\n换行\v纵向制表符\t横向制表符\r回车\f换页\oyy八进制数yy代表的字符,例如:\o12代表换行\xyy十进制数yy代表的字符,例如:\x0a代表换行\other其它的字符以普通格式输出 阅读全文
posted @ 2011-04-28 10:48 runfox545 阅读(152638) 评论(5) 推荐(3)
摘要: # 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 阅读(735) 评论(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 阅读(2453) 评论(0) 推荐(0)
摘要: List MethodsHere are some other common list methods.list.append(elem) -- adds a single element to the end of the list. Common error: does not return the new list, just modifies the original. list.insert(index, elem) -- inserts the element at the given index, shifting elements to the right. list.exte 阅读全文
posted @ 2011-04-26 17:03 runfox545 阅读(1947) 评论(0) 推荐(0)
摘要: sorted(...) sorted(iterable, cmp=None, key=None, reverse=False) --> new sorted listiterable:是可迭代类型;cmp:用于比较的函数,比较什么由key决定,有默认值,迭代集合中的一项;key:用列表元素的某个属性和函数进行作为关键字,有默认值,迭代集合中的一项;reverse:排序规则. reverse = True 或者 reverse = False,有默认值。返回值:是一个经过排序的可迭代类型,与iterable一样。refer to :http://wiki.python.org/moin/H 阅读全文
posted @ 2011-04-26 15:12 runfox545 阅读(1123) 评论(1) 推荐(0)
摘要: #!/usr/bin/python -tt# Copyright 2010 Google Inc.# Licensed under the Apache License, Version 2.0# http://www.apache.org/licenses/LICENSE-2.0# Google's Python Class# http://code.google.com/edu/languages/google-python-class/# Basic string exercises# Fill in the code for the functions below. main( 阅读全文
posted @ 2011-04-25 17:13 runfox545 阅读(434) 评论(0) 推荐(0)
摘要: Here are some of the most common string methods. A method is like a function, but it runs "on" an object. If the variable s is a string, then the code s.lower() runs the lower() method on that string object and returns the result (this idea of a method running on an object is one of the ba 阅读全文
posted @ 2011-04-22 14:08 runfox545 阅读(536) 评论(0) 推荐(0)
摘要: Python is packaged with many standard modules which are bundled with a standard installation of the python interpreter, so you don't have do anything extra to use them. Commonly used standard python modules include:sys -- access to exit(), argv, stdin, stdout, ... re -- regular expressions os -- 阅读全文
posted @ 2011-04-22 11:17 runfox545 阅读(203) 评论(0) 推荐(0)
摘要: URL: http://code.google.com/intl/zh-CN/edu/Thanks Google Guys for sharing those information to us!Enjoy it! 阅读全文
posted @ 2011-04-21 17:28 runfox545 阅读(267) 评论(0) 推荐(0)
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 50 下一页
白月黑羽 Python教程 白月黑羽Python