[英]How to pause a loop print in python
我有以下代碼:
i = 0
numbers = []
while i < 6:
print ("At the top i is %d" % i)
numbers.append(i)
i = i + 1
print ("Numbers now: ", numbers)
print ("At the bottom i is %d" % i)
print ("The numbers: ")
for num in numbers:
print (num)
如果導入sleep
它將使速度變慢,但是如何暫停它,以便在需要時繼續進行呢?
只需在要暫停的位置添加input()
即可。
i=0
numbers = []
while i < 6:
print("At the top i is %d" % i)
numbers.append(i)
i = i + 1
print("Numbers now: ", numbers)
print("At the bottom i is %d" % i)
input() # add it here for example.
print("The numbers: ")
for num in numbers:
print(num)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.