1
嗨我试图运行基于用户的输入功能,我做错了什么?Tkinter按键触发事件
,如果我做
def onKeyPress(input = 1 | 2):
playSound
如果我按1或2
,但如果我这样做
def onKeyPress(input = 1 | 2):
if input == 1:
command = playSound()
elif input == 2:
command = nextFile()
我得到什么,如果我按1或2个能正常工作,没有任何反应。我假设即时通讯不检查输入是否正确1或2?谢谢
你怎么看'输入= 1 | 2'在做什么,确切地说?它只是使默认值'3',它没有测试任何东西。 – jonrsharpe 2014-11-22 16:24:24
我通常使用C++编程,所以python对我来说是陌生的,我认为它的意思是'or'in C++ ||是或 – user3423572 2014-11-22 16:34:42
是的,这是一个按位或,但为什么不只是设置'input = 3'? – jonrsharpe 2014-11-22 16:35:45