标签:python pre out pytho 枚举 str code 变量类型 bsp
In [140]: a=‘hello‘ In [141]: len(a) Out[141]: 5
In [142]: max(‘1234‘) Out[142]: ‘4‘ In [143]: min(‘1234‘) Out[143]: ‘1‘
可以同时遍历索引和遍历元素
In [151]: str=‘hello‘ In [152]: for i,j in enumerate(str): .....: print i,j .....: 0 h 1 e 2 l 3 l 4 o
cmp()
In [37]: cmp(1,2) Out[37]: -1 In [38]: cmp(2,1) Out[38]: 1 In [39]: cmp(1,1) Out[39]: 0
type(变量名)
In [42]: a=1 In [43]: type(a) Out[43]: int
In [35]: a=123 In [36]: type(a) Out[36]: int In [37]: a=long(a) In [38]: type(a) Out[38]: long
In [40]: str(1) Out[40]: ‘1‘
In [153]: s1=‘123‘ In [154]: s2=‘abc‘ In [155]: s3=‘ABC‘ In [156]: zip(s1,s2,s3) Out[156]: [(‘1‘, ‘a‘, ‘A‘), (‘2‘, ‘b‘, ‘B‘), (‘3‘, ‘c‘, ‘C‘)]
标签:python pre out pytho 枚举 str code 变量类型 bsp
原文地址:https://www.cnblogs.com/vaon/p/10909140.html