[英]How can I tell if a certain key was pressed in Python?
import sys
print (sys.platform)
print (2 ** 100)
input('press Enter to exit')
Suppose I wanted to use the number 1 as the button that must be pressed to exit. 假设我想使用数字1作为必须按下以退出的按钮。 How would I go about doing this? 我将如何去做呢?
Something like this? 像这样吗
http://mail.python.org/pipermail/python-list/1999-October/014262.html http://mail.python.org/pipermail/python-list/1999-October/014262.html
Not so clean, but doable. 不是很干净,但是可行。
Something like this will do what you want: 这样的事情会做你想要的:
while(raw_input('Press "1" to exit.') != '1'):
pass
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.