我确信很容易看出我在这里想要做什么。我是完全错误还是犯了一个简单的错误?我想说的是:
'PlayerA's name', Please choose..
playerA = raw_input("Please enter your name: ")
playerB = raw_input("Please enter your name: ")
choiceA = input("%s, Please choose; Rock (R), Paper (P), or Scissors (S): ") % (playerA)
choiceB = input("%s, Please choose; Rock, Paper, or Scissors: ") % (playerB)
最佳答案
您的替换需要完全在括号内完成:
raw_input("%s, Please choose; Rock (R), Paper (P), or Scissors (S): " % (playerA))
否则它将根据调用的结果来完成。
此外,您似乎没有理由有时使用 raw_input 而有时使用输入。如果您使用的是 Python 2,请始终使用 raw_input。
关于python - 在输入提示中使用字符串格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32993524/