1. 子list是拷贝,不是引用。改变得到的字符串不会改变原来的字符串
2. [k+1 for k in a if type(k) == types.IntType]
3. s = """abc
def"""
print s
输出
abc
def
注意换行和空格
4. a = [1, 1, 2]
a.remove(1)只会去掉第一个1
5. "ok abc".rfind("abc") #3 反向查找,索引还是按照正顺序的索引
6. find和index都能返回索引,但是index找不到的时候抛出异常,处理方式太粗暴
7. print "%(name)s is %(height)d cm" % {"name" : "Charles", "height" : 180}
8. def SayHello(a, b):
print "a is %(a)d, b is %(b)d" % locals()
SayHello(1, 2)
9. " s \t\t ".lstrip().rstrip()
strip() strip("\t \r\n")
10. " ".join(["this", "is", "a", "bee"])
"this is a bee".split(" ")
11. 表示一个元素的turple (123, )
12. dictionary key的类型是integer或者string,或者是同时含有__hash__和__cmp__方法的对象
13. pricelist = dict([("clock", 12), ("table", 100), ("xiao", 100)])
读不存在的key会抛出异常
14.