How to include variables in a string?
本问题已经有最佳答案,请猛点这里访问。
我正在做一些课程,我需要确定一个角色的名字。这就是我目前为止所拥有的:
1 2 | charOne=input("Please input your first character's name:") charTwo=input("Please input your second character's name:") |
所以用户输入名称,现在我需要让用户选择其中一个字符。
1 | chooseCharacter=input("What character do you want to use?" |
我需要把用户charone和chartwo放到问题中。或者某种方式需要让用户选择他们想要使用的用户。
使用python字符串格式:
1 2 3 4 | charOne = input("Please input your first character's name:") charTwo = input("Please input your second character's name:") chooseCharacter = input("What character do you want to use? (%s or %s):" % (charOne, charTwo)) |