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

python数据类型

时间:2017-08-14 21:23:52      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:浮点   python2   32位   int   pytho   long   取值   oat   类型   

int(整形)

整数在python2整形、长整形。 32位取值范围-2**31~2**31-1。64位整形,取值范围为-2**63-3**63-1。

long(长整形)

python3 里面没有long

float(浮点数)

布尔值

1或0

真或假

a = 0
if a:print(a)
a = 1
if a:print(a)
a

complex(复数)

%取模

8%2 

0

9%2

1

最简单的求解

取整除

10.3//3

3.9

10.3/3

3.4333333

运算符

技术分享

 

==  等于

!=不等于

<>不等于

赋值运算

 技术分享

逻辑运算

and,or,not

a,b,c = 3,5,7
a >2 and c < 7
False
a > 2 and c < 8 and b > 4
True
a > 2 and c < 8 and b > 4 or c == 8
True
a > 2 and c < 2 and b > 4 or c == 8
False

not

a = "333"
if not a.isdigit():print("ddd")
a = "aaa"
if not a.isdigit():print("ddd")
ddd

in  

not in 

技术分享\

is is not

技术分享

 

python数据类型

标签:浮点   python2   32位   int   pytho   long   取值   oat   类型   

原文地址:http://www.cnblogs.com/fsdl1988/p/7359915.html

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