當前位置:首頁 » 編程語言 » 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!

熱點內容
中國海軍訪問朝鮮 發布:2025-10-13 06:30:00 瀏覽:544
夢幻西遊手游怎麼用蘋果玩安卓 發布:2025-10-13 06:22:19 瀏覽:794
下面演算法 發布:2025-10-13 06:22:19 瀏覽:755
psd作圖突然無法存儲怎麼辦 發布:2025-10-13 06:15:53 瀏覽:209
插頁式文件夾頁 發布:2025-10-13 06:03:43 瀏覽:538
android定義枚舉 發布:2025-10-13 05:46:33 瀏覽:710
sqlite3編譯時如何處理 發布:2025-10-13 05:45:07 瀏覽:897
收銀主伺服器在什麼地方 發布:2025-10-13 05:44:18 瀏覽:855
學軟體編程好不 發布:2025-10-13 05:43:36 瀏覽:865
linuxudp數據接收數據 發布:2025-10-13 05:40:43 瀏覽:52