python - 忽略输入或延迟下一个输出
问题描述
我设置了一个输入来延迟下一个输出,但是在忽略输入时出现错误。有没有办法忽略输入或延迟输出的另一种方法。我非常感谢您的帮助
错误:
Traceback (most recent call last):
File "<pyshell#7>", line 11, in <module>
b = int(input())
ValueError: invalid literal for int() with base 10: ''
代码:
while True:
print("Tissues")
print(" Plant tissues")
print(" Meristametic tissues")
a = str(input(": "))
print()
if a == "Tissues":
print("A group of cells modified to perform a specific function")
elif a == "Meristametic tissues":
print("A group of cells in a tissue that rapidly divides by Mitosis to form new cells")
b = int(input())
解决方案
为了延迟输入,您应该使用:
import time
time.sleep(<SECONDS>)
如果你想跳过给定的答案,你总是可以使用关键字continue
来移动到循环的下一个迭代。最后一部分——你试图用这条线做 b = int(input())
什么?为了将输入放入变量中,b
您应该删除int()
问题将消失的转换。