码迷,mamicode.com
首页 > 编程语言 > 详细

Python数据类型-7

时间:2019-03-30 16:09:44      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:false   list   ict   效率   三方   字典   用户   lse   判断   


什么数据类型。
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

 

Python数据类型-7

标签:false   list   ict   效率   三方   字典   用户   lse   判断   

原文地址:https://www.cnblogs.com/LXL616/p/10627596.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!