我只是乱搞一个简单的程序,如:
import random
game = True
body = ['right foot', 'left foot', 'right hand', 'left hand']
color = ['red', 'blue', 'green', 'yellow']
while game:
userinput = input('What would you like to do?')
if userinput == '':
random1 = random.choice(body)
random2 = random.choice(color)
print(random1 + ' ' + random2)
if userinput == 'quit':
game = False
我想知道,不是让用户输入quit,我怎么能让按下转义键时程序退出?