C语言中while(c = gatchar()>0)可以持续从键盘获的字符,在python中如何实现
python 中 input() 函数可以接受键盘输入,注意获取的是 str 类型。下面代码持续获取字符输入,直到输入为空(直接回车)终止。
input()
str
while True: x = input('Enter your data: ') if not x: break # do your work here ...