Python 打印语音标记中的变量
我询问用户的物理属性(头发颜色、眼睛颜色等) 我怎样才能打印出描述 你好(查隆)我说你有(定义的)头发(定义的)对吗 眼睛Python 打印语音标记中的变量,python,Python,我询问用户的物理属性(头发颜色、眼睛颜色等) 我怎样才能打印出描述 你好(查隆)我说你有(定义的)头发(定义的)对吗 眼睛 我不知道你从哪里得到的(“%s”)=(…)。我以前从未见过这样的事。确保将您的代码与已知的好代码进行比较 最后一行应该是: print 'hello %s. Am i right to say you have %s right?. You should also be %s and have %s eyes.' % (charOne, hair, build, eyes)
我不知道你从哪里得到的
(“%s”)=(…)
。我以前从未见过这样的事。确保将您的代码与已知的好代码进行比较
最后一行应该是:
print 'hello %s. Am i right to say you have %s right?. You should also be %s and have %s eyes.' % (charOne, hair, build, eyes)
或者分成两行:
print 'hello %s. Am i right to say you have %s right?' % (charOne, hair)
print 'You should also be %s and have %s eyes.' % (build, eyes)
首先,确保“如果”后面的缩进是正确的。 那么,最后一行似乎是错的 此示例将起作用:
charOne="a"
charTwo="b"
chooseCharacter = input("What character do you want to use? (%s or %s): " % (charOne, charTwo))
if chooseCharacter=="%s" % charOne:
attributes = []
hair= input("what colour hair does %s have?" % (charOne))
build= input("what build is %s?" % (charOne))
eyes= input("what colour eyes does %s have?" % (charOne))
weaponOfChoice= input("what weapon is %s using?" % (charOne))
defence= input("what defence does %s use?" % (charOne))
s=('hello %s. Am i right to say you have %s right?. You should also be %s and have %s eyes.' % (charOne,hair, build,eyes))
print(s)
当您说“它不工作”时,会出现什么错误?如果您在尝试运行它时包含当前获得的确切输出,则会很有帮助。要打印,请使用
print
。没有那么奇怪的(“%s”)=
。
charOne="a"
charTwo="b"
chooseCharacter = input("What character do you want to use? (%s or %s): " % (charOne, charTwo))
if chooseCharacter=="%s" % charOne:
attributes = []
hair= input("what colour hair does %s have?" % (charOne))
build= input("what build is %s?" % (charOne))
eyes= input("what colour eyes does %s have?" % (charOne))
weaponOfChoice= input("what weapon is %s using?" % (charOne))
defence= input("what defence does %s use?" % (charOne))
s=('hello %s. Am i right to say you have %s right?. You should also be %s and have %s eyes.' % (charOne,hair, build,eyes))
print(s)