数字字符串转整型,浮点型,字符串要求全为数字
(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)
字典:hash
k= {key1:value1,key2:value2,key3:value3 }
c=k[key1]
key in dic
dic.get(key)
dic.pop(key)
集合:
k={a,b,c}
k=set([a,b,c])
>>> a={2,3,5}
>>> type(a)
<class 'set'>
add() remove() | &
>>> bool(1)
True
>>> bool('')
False