日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > python >内容正文

python

python booleans_Python 2.1 BooleansComparisons

發(fā)布時(shí)間:2025/4/16 python 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python booleans_Python 2.1 BooleansComparisons 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Booleans#布爾值

Another type in Python is the Boolean type.There are two Boolean values: True and False.

They can be created by comparing values, for instance by using the equal operator ==.

>>> my_boolean = True

>>> my_boolean

True

>>> 2 == 3

False

>>> "hello" == "hello"

True

Python中的另一種類型是布爾類型。有兩個(gè)布爾值:True和False。

它們可以通過(guò)比較值來(lái)創(chuàng)建,例如使用等號(hào)操作符==。

>>> my_boolean = True

>>> my_boolean

True

>>> 2 == 3

False

>>> "hello" == "hello"

True

Be careful not to confuse assignment (one equals sign) with comparison (two equals signs).

注意不要混淆賦值(一個(gè)等號(hào))和比較(兩個(gè)等號(hào))。

Comparison#比較

Another comparison operator, the not equal operator (!=), evaluates to True if the items being compared aren't equal, and False if they are.

>>> 1 != 1

False

>>> "eleven" != "seven"

True

>>> 2 != 10

True

另一個(gè)比較操作符not equal操作符(!=)在被比較的項(xiàng)不相等時(shí)計(jì)算為True,如果相等則為False。

>>> 1 != 1

False

>>> "eleven" != "seven"

True

>>> 2 != 10

True

Python also has operators that determine whether one number (float or integer) is greater than or smaller than another.These operators are > and < respectively.

>>> 7 > 5

True

>>> 10 < 10

False

Python也有一些運(yùn)算符來(lái)確定一個(gè)數(shù)字(浮點(diǎn)數(shù)或整數(shù))是大于還是小于另一個(gè)。這些操作符分別是>和

>>> 7 > 5

True

>>> 10 < 10

False

The greater than or equal to, and smaller than or equal to operators are >= and <=.

They are the same as the strict greater than and smaller than operators, except that they return True when comparing equal numbers.

>>> 7 <= 8

True

>>> 9 >= 9.0

True

大于或等于、小于或等于運(yùn)算符的是>=和<=。

它們與嚴(yán)格的大于和小于操作符相同,只是在比較相等的數(shù)字時(shí)返回True。

>>> 7 <= 8

True

>>> 9 >= 9.0

True

Greater than and smaller than operators can also be used to compare strings lexicographically (the alphabetical order of words is based on the alphabetical order of their component letters).

大于和小于操作符還可以用于按字典順序比較字符串(單詞的字母順序基于其組成字母的字母順序)。

總結(jié)

以上是生活随笔為你收集整理的python booleans_Python 2.1 BooleansComparisons的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。