对不起,如果我问了一些愚蠢的问题。顺便说一句,我是乞丐。 我是否可以在一个变量中放入多个变量,如:
login = "user"
enter = input(login + ">")
commandLogin = "login"
commandRegister = "register"
commandExit = "exit"
commandList = commandLogin, commandRegister, commandExit
while enter != commandList:
print("incorrect command!")
enter = input(login + ">")
您可以使用“iterable”,例如
tuple
或list
。点击这里:Python docs因此,对于您的代码,您可以使用:
当然。可以使用字典将多个变量放入一个变量中:
还可以创建类、类的对象和访问属性:
在您的示例中,您可能希望使用以下列表:
但在你的例子中,你想做什么还不是很清楚
在这个例子中,你已经在做了
主要的修正是您可能想要
while enter not in commandList
相关问题 更多 >
编程相关推荐