返回顶部

欢迎来到菜鸟大明儿哥的博客

我们一起交流学习,不断提升自我

Python 数据类型(1)------整型(int)和布尔型(bool)

3.1 整型 (int)

3.1.1整型的长度

py2中有: int/long

32位电脑 -2147483648 – 2147483647

64位电脑 -9223372036854775808 –9223372036854775807

超出范围后python自动转换成long类型

py3中有:int( int/long) 不转换,只有int类型

 

3.1.2整除

Py2默认除法就是地板除 v1=9/2 =4

需要先执行from future import division

 

 

message = 'abc'
print(message)
b = int(message)

 

 

3.2布尔(bool)

布尔值就是用于表示真假True或False

其他类型转换成布尔值

  • str ""是False,其他都是True

  • 数字 0是False,其他都是True

posted @ 2020-08-28 10:49  菜鸟大明儿哥  阅读(382)  评论(0编辑  收藏  举报