kp = keypad()
list = ['']
digit = None
while True:
digit = kp.getKey()
if digit != None and digit != '*':
list.append(str(digit))
time.sleep(.5) #otherwise you end up repeating the same number until a new one is pressed
digit = None
elif digit = '*':
print ''.join(list)
break
好吧,我想好了:
这将一直等到你点击一个或多个键,如果这个键是*那么它会打印你的号码并结束循环。在
希望这能帮助其他人解决这个问题。在
查看原始代码,
kp.getKey()
偶尔会返回None
。编写循环以附加到列表中,直到列表包含两个使用相同逻辑的元素:相关问题 更多 >
编程相关推荐