iT邦幫忙

0

請問python裡的not(Variable) 在 while迴圈的第一行裡的運作原理

https://ithelp.ithome.com.tw/upload/images/20220520/201491803AqcVkSQWE.png
這圖裡的code是這樣的:
sth = False
while not(sth):
print(not(sth))

print("what is going on?")

請問這個not(sth)是預設==False的時候會執行while迴圈而==True的時候則不執行嗎?

可是我覺得很奇怪耶因為這裡應該要寫一些condition的東西,可是not(sth)就只是True而已,True代表的是布林值又不是什麼condition。如果是condition應該要寫not(sth)==True才對吧。

抱歉可能有些用語表達的不好,小弟剛學不到一個星期...請大家不吝指教!

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
海綿寶寶
iT邦大神 1 級 ‧ 2022-05-20 22:12:31
最佳解答
The while Loop

With the while loop we can execute a set of statements as long as a condition is true.

你所謂的 condition
不管多複雜或多簡單
最終的結果只有 True/False 兩種
參考資料來源

我要發表回答

立即登入回答