Python3input()似乎在两次调用之间采用旧的 std 输入input()。有没有办法忽略旧输入,只接受新输入(在input()被调用后)?
import time
a = input('type something') # type "1"
print('\ngot: %s' % a)
time.sleep(5) # type "2" before timer expires
b = input('type something more')
print('\ngot: %s' % b)
输出:
$ python3 input_test.py
type something
got: 1
type something more
got: 2
哆啦的时光机
相关分类