1、Python字符串格式化:http://www.cnblogs.com/JerySpace/archive/2010/12/17/1909621.html
2、enumerate()用法:在同时需要用到index和value值的时候可以用到enumerate,参数为可遍历的变量,如字符串,列表等,返回enumerate类。 http://www.pythonclub.org/python-basic/built-in
3、read(), readline(), readlines(), xreadlines()
http://blog.csdn.net/longshenlmj/article/details/12570271
xreadlines的原理和xrange差不多。但现在也不推荐使用xreadlines,详见:http://www.oschina.net/question/252490_132790
4、sort(),sorted()
一个排序函数都这么博大精深。学无止境啊!
https://wiki.python.org/moin/HowTo/Sorting
一个简单些的讲解:http://www.jb51.net/article/52730.htm
需要注意:sort(a_list) 修改a_list,但是sorted(a_list) 并不修改a_list,而是生成一个副本
>>> x = [3,2,5,0,1]
>>> x.sort()
>>> print x
[0, 1, 2, 3, 5]
>>> x = [3,2,5,0,1]
>>> print sorted(x)
[0, 1, 2, 3, 5]
>>> print x
[3, 2, 5, 0, 1]
5、如果一个function里的argument前面有*,它的作用是生成tuple,长度不限:
>>> def func(argu1, *argu2):
... print argu1
... print argu2
...
>>> func('A','B','C','D')
A
('B', 'C', 'D')
6、Python2.x和3.x中,urllib的区别:
a new urllib package was created. It consists of code from
urllib, urllib2, urlparse, and robotparser. The old
modules have all been removed. The new package has five submodules:
urllib.parse, urllib.request, urllib.response,
urllib.error, and urllib.robotparser. The
urllib.request.urlopen() function uses the url opener from
urllib2. (Note that the unittests have not been renamed for the
beta, but they will be renamed in the future.)
7、所有标准序列操作,例如分片索引等,对字符串都是适用的,但是字符串都是不可变的,要注意不能对分片数据进行赋值。
8、chr(), unichr(), ord()
http://www.xuebuyuan.com/2067536.html
320

被折叠的 条评论
为什么被折叠?



