Python数据类型-7

 

什么数据类型。
int 1,2,3用于计算。
bool:True,False,用户判断。
str:存储少量数据,进行操作
'fjdsal' '二哥','`13243','fdshklj'
'战三,李四,王二麻子。。。。'
list:储存大量的数据。
[1,2,3,'泰哥','12353234',[1,2,3]]
元祖:只读。
(1,2,3,'第三方',)
dict:字典{'name':'云姐','age':16}
字典{'云姐':[],'二哥':[200,200,200,。。。。。。]}
集合:{1,2,34,'asdf'}
3,int。

4,bool。
5,str。

i = 100
print(i.bit_length())
'''
                  bit_length
1     0000 0001       1
2     0000 0010       2
3     0000 0011       2
'''
#bool  True False

#int ----> str
i = 1
s = str(i)
#str ---> int
s = '123'
i = int(s)

#int ----->bool  只要是0 ----》False  非0就是True
i = 3
b = bool(i) print(b) #bool----> int #True 1 #False 0 ''' ps: while True: pass while 1: 效率高 pass ''' #str --->bool #s = "" -----> False #非空字符串都是True #s = "0" -----> True  s if s: print('你输入的为空,请重新输入') else: pass

猜你喜欢

转载自www.cnblogs.com/LXL616/p/10627596.html
今日推荐