一旦程序打印,它就會關閉。如何讓它返回到代碼的頂部,以便它循環,無限期地詢問用戶名?如何循環此程序?
代碼:
from time import sleep
name = raw_input ("Please enter your name: ")
print "Hello", name, "- good to see you!"
sleep(2.00)
僞代碼:
from time import sleep
A
name = raw_input ("Please enter your name: ")
print "Hello", name, "- good to see you!"
sleep(2.00)
return to A
你甚至讀過關於python的一件事嗎?你怎麼知道如何在不知道什麼是循環的情況下導入模塊 – Falmarri 2010-08-24 03:20:33
當然,僞代碼使用goto。 「Dijkstra不會喜歡這個」;) – delnan 2010-08-24 05:42:32
這是我正在開發的程序的測試程序。我遇到了一個問題,所以我試圖在簡化的層面上獲得我想要的行爲。由於正常循環方法不起作用。 – rectangletangle 2010-08-27 00:47:10