[英]How to pause a loop print in python
I have the following code: 我有以下代码:
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)
If I import sleep
it will slow it down, but how can I pause it so it proceeds when I want it to? 如果导入sleep
它将使速度变慢,但是如何暂停它,以便在需要时继续进行呢?
Just add input()
where you want it to pause. 只需在要暂停的位置添加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.