python小细节

1.python不支持i++,但有i+=1和i-=1

2.可以通过help()查询帮助信息,比如help(range)就可以查看range的帮助信息

3.python的list的下标是从0开始的

4.int()函数字符串转int型,float()函数字符串转float型,str()函数字符串转int型

5.len函数既可以计算list的长度,也可以计算字符串的长度

6.注意这段代码生成的list的形状:

>>> a = [range(3) for i in range(5)]
>>> a
[[0, 1, 2], [0, 1, 2], [0, 1, 2], [0, 1, 2], [0, 1, 2]]

 

posted @ 2016-12-30 12:01  有梦就要去实现他  阅读(207)  评论(0编辑  收藏  举报