我这里只有一个小程序,我想用它来接受用户的输入(就像输入密码一样)。我有一个包含密码的列表,然后我将用户输入并将其放在一个空类中。然后将该类与其中包含密码的类进行比较,如果匹配,它将返回“好”。但是,我只能使用一位数来做到这一点。如何允许用户使用多个整数?这是做这类事情的有效方法吗?有没有更快更有效的方法?谢谢。
class KeyCode(object):
def access(self):
room_code = [1]
print "Before you enter you must provide the room code: "
attempt = []
code = int(raw_input('>>'))
attempt.append(code)
if attempt == room_code:
print "Good"
else:
return 'death'
class Boxing_room(KeyCode):
def enter(self):
print "This is the boxing studio"
return 'Gymnast_room'