如何在字符串中包含变量?
How to include variables in a string?
我正在做一些课程作业,我需要确定一个角色的名字。这是我目前所拥有的:
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?"
我需要将用户 charOne 和 charTwo 放入问题中。或者某种方式需要让用户选择他们想要使用的用户。
使用Python字符串格式:
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))
我正在做一些课程作业,我需要确定一个角色的名字。这是我目前所拥有的:
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?"
我需要将用户 charOne 和 charTwo 放入问题中。或者某种方式需要让用户选择他们想要使用的用户。
使用Python字符串格式:
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))