我刚刚开始学习Python,我正在制作一个小游戏来练习我学到的东西。不过,我遇到了一个小问题:
name = raw_input("Enter Name: ")
print""
print "^^^^^^^^^^^^^^^^^^"
start_message = raw_input("Another day on Uranus, {name}!. Shall we go outside or stay within the protection bubble? (Press 'Enter')").format(name=name)
Enter Name: James
^^^^^^^^^^^^^^^^^^
Another day on Uranus, {name}!. Shall we go outside or stay within the protection bubble? (Press 'Enter')
答案 0 :(得分:1)
啊你有一个括号错误。
start_message = raw_input("Another day on Uranus, {name}!. Shall we go outside or stay within the protection bubble? (Press 'Enter')").format(name=name)
需要
start_message = raw_input("Another day on Uranus, {name}!. Shall we go outside or stay within the protection bubble? (Press 'Enter')".format(name=name))
答案 1 :(得分:0)
您需要格式化传递给 ......(Press 'Enter')".format(name=name)
raw_input
您正尝试格式化您从SELECT pos
FROM (
SELECT ROW_NUMBER() OVER() AS pos, h
FROM (FLATTEN((
SELECT SPLIT(RPAD('', :VAR_END, '.'),'') AS h FROM (SELECT NULL)),h
)))
WHERE pos BETWEEN :VAR_START AND :VAR_END
AND (pos - :VAR_START) % :VAR_STEP = 0
获得的输入。
答案 2 :(得分:0)
您正在格式化raw_input
而不是raw_input
中的字符串。您需要更改括号的位置:
start_message = raw_input("Another day on Uranus, {name}!. Shall we go outside or stay within the protection bubble? (Press 'Enter')".format(name=name))
请注意,我在结束"
之后从format
之后拉出括号,现在全部都在raw_input()
输出:
Enter Name: Andy
^^^^^^^^^^^^^^^^^^
Another day on Uranus, Andy!. Shall we go outside or stay within the protection bubble? (Press 'Enter')