首页 > 编程语言 > 详细

python,运算符,基本数据类型

时间:2019-03-29 15:41:30      阅读:140      评论:0      收藏:0      [点我收藏+]
a = py in python
b = py not in python
print(a)
print(b)

in :判断一个前面一个字符串中的字符是否完整的出现在后面的字符串中,如果完整的出现过则输出True,否则输出False

not in :和in相反,如果没有完整出现过则输出True,否则输出False

 

比较运算:

==

>

<

>=

<=

!= 不等于

<> 不等于

 

逻辑运算:

and:用来比较多个比较运算,真真为真,真假为假,假假为假

a = True and True
b = True and False
c = False and True
d = False and False
print(a)#结果为真
print(b)#结果为假
print(c)#结果为假
print(d)#结果为假

 

or:和and一样是用来比较多个比较运算,但是,真真为真,真假为真,假假为假

a = True or True
b = True or False
c = False or True
d = False or False
print(a)#结果为真
print(b)#结果为真
print(c)#结果为真
print(d)#结果为假

 

not:如果逻辑运算为假则返回真,真则返回假

a = not(True)
b = not(False)
print(a)#结果为假
print(b)#结果为真

 

a = 123
print(type(a),a)
b = int(a)
print(type(b),b)

int():强制转换成数字类型

type():返回输入值的类型

print(int(0111,base=2))

int(‘‘,base=):把输入的值转换成二进制,base里面的值会改变他转换成的值,base的范围是2<=base<=36

python,运算符,基本数据类型

原文:https://www.cnblogs.com/xonghaizi/p/10582833.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!