當前位置:首頁 » 編程語言 » pythonwhile用法

pythonwhile用法

發布時間: 2025-10-13 04:26:03

pythonwhile循環的用法是什麼

python while循環語句:

while 判斷條件(condition):

執行語句(statements)……

執行語句可以是單個語句或語句塊。判斷條件可以是任何錶達式,任何非零、或非空(null)的值均為true。

當判斷條件假 false 時,循環結束。

實例:

#!/usr/bin/python

count = 0

while (count < 9):

print 'The count is:', count

count = count + 1

print "Good bye!"

運行實例 »

以上代碼執行輸出結果:

The count is: 0

The count is: 1

The count is: 2

The count is: 3

The count is: 4

The count is: 5

The count is: 6

The count is: 7

The count is: 8

Good bye!

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:710
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:972
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:681
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:833
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:741
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1081
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:312
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:192
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:879
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:837