标签:
数字字符串转整型,浮点型,字符串要求全为数字
(int)("222")
(float)("2222")
布尔型:转为整形
int(True)-->1
int(False)--->0
整形,浮点型转字符串
str(1),str(11.2)
>>> a=range(5)
>>> list(a)
[0, 1, 2, 3, 4]
>>> a
range(0, 5)
>>> list(range(5))
[0, 1, 2, 3, 4]
>>> type(a)
<class ‘range‘>
>>> type([2])
<class ‘list‘>
L = (‘Bart‘, ‘Lisa‘, ‘Adam‘)
for x in L:
print(x)
L = [‘Bart‘, ‘Lisa‘, ‘Adam‘]
for x in L:
print(x)
标签:
原文地址:http://www.cnblogs.com/zengkefu/p/5568819.html