python運算符號詳細介紹
更新時間:2021年12月27日 10:35:30 作者:是數(shù)學系的小孩兒
大家好,本篇文章主要講的是python運算符號詳細介紹,感興趣的同學趕快來看一看吧,對你有幫助的話記得收藏一下,方便下次瀏覽
比較運算符

a,b=10,30
print('a>b嗎?',a>b)
print('a<b嗎?',a<b)
print('a<=b嗎?',a>=b)
print(a is b)#這個比較的是id標識
a>b嗎? False a<b嗎? True a<=b嗎? False False
一個變量有三部分組成:1標識,2類型,3值
比較對象的標識使用is
布爾運算符

print(a==1 and b==2)#ture and true-->ture
print(a==1 and b<2)#ture and false-->false
print(a!=1 and b==2)#false and ture-->false
print(a!=1 and b!=2)#false and false -->false
print('---------------or 或者-----------------------------------------')
print(a==1 or b==2)#ture or true-->ture
print(a==1 or b<2)#ture or false-->ture
print(a!=1 or b==2)#false or ture-->ture
print(a!=1 or b!=2)#false and false -->false
print('---------------not 對運算數(shù)取反-----------------------------------------')
f=True
f2=False
print(not f)
print(not f2)
print('---------------in 與not in-----------------------------------------')
s='helloworld'
print('w'in s)
print('k'in s)
print('w'not in s)
print('k'not in s)
True True False False False ---------------or 或者----------------------------------------- True True True False ---------------not 對運算數(shù)取反----------------------------------------- False True ---------------in 與not in----------------------------------------- True False False True
python中的位運算符


運算符的優(yōu)先級



到此這篇關于python運算符號詳細介紹的文章就介紹到這了,更多相關python運算符內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
python3操作微信itchat實現(xiàn)發(fā)送圖片
這篇文章主要為大家詳細介紹了python3操作微信itchat實現(xiàn)發(fā)送圖片,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-02-02
python3 使用openpyxl將mysql數(shù)據(jù)寫入xlsx的操作
這篇文章主要介紹了python3 使用openpyxl將mysql數(shù)據(jù)寫入xlsx的操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-05-05
Python操作MySQL數(shù)據(jù)庫9個實用實例
這篇文章主要介紹了Python操作MySQL數(shù)據(jù)庫9個實用實例,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2015-12-12
Python多線程編程(八):使用Event實現(xiàn)線程間通信
這篇文章主要介紹了Python多線程編程(八):使用Event實現(xiàn)線程間通信,,需要的朋友可以參考下2015-04-04
刪除DataFrame中值全為NaN或者包含有NaN的列或行方法
今天小編就為大家分享一篇刪除DataFrame中值全為NaN或者包含有NaN的列或行方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-11-11

