我刚开始学习Python。
placemarker = 1
while True:
print ("Welcome")
command = input ("Enter command: ")
if command == register:
placemarker = 20
if placemarker == 20:
registerMe = input ("What is your name? ")
当我将注册输入输入时,我试图链接到地标20区域。我怎么能实现这个目标?谢谢,我只是一个初学者。 :)
答案 0 :(得分:0)
placemarker = 1
while True:
print ("Welcome")
command = input ("Enter command: ")
if command == "register": #String variable here
placemarker = 20
if placemarker == 20:
registerMe = input ("What is your name? ")
像这样更改它,你应该告诉Python它是一个字符串,因为input
将变量存储为字符串。你也可以这样写清楚 - 比你的代码清楚;
while True:
print ("Welcome")
command = input ("Enter command: ")
if command == "register": #String variable here
registerMe = input ("What is your name? ")
print (registerMe) #print or do whatever you want on here
break
答案 1 :(得分:0)
方法input()
会返回String
,因此在if
语句中您必须将register
字词更改为"register"
,因为变量{{1将是一个字符串:因此if语句在command
之后寻找一个字符串。 希望这有助于