.format()的语法错误(Python 3.2.3)

.format()的语法错误(Python 3.2.3),python,Python,所以我试着写一个程序,写一个单词,用标记()填充20个空格,然后向后写同一个单词。它还需要用户输入。 谁能告诉我我做错了什么 while test2 == 1 : test = input("Enter a word to format. Entering QUIT will exit the program:") if test == ("quit"): print("You have quit the program.") break

所以我试着写一个程序,写一个单词,用标记(<或>)填充20个空格,然后向后写同一个单词。它还需要用户输入。 谁能告诉我我做错了什么

 while test2 == 1 : 
    test = input("Enter a word to format. Entering QUIT will exit the program:")
    if test == ("quit"):
        print("You have quit the program.")
        break
    else:
        print("{0:*<20}{1:*>20})".format(
            "test")(["test"::-1])
当test2==1时:
测试=输入(“输入要格式化的单词。输入QUIT将退出程序:”)
如果测试==(“退出”):
打印(“您已退出程序。”)
打破
其他:
打印(“{0:*20})”。格式(
“测试”)([“测试”:-1])

从语法上讲,您上次打印的
语句中有一个
放在错误的位置

print("{0:*<20}{1:*>20}").format("test")(["test"::-1])
                       ^

您的最后一行有错误,请尝试以下操作,以在单词之间留出20个空格

In [1]: s = "test"
In [2]: print('{0:<20}{1}'.format(s,s[::-1]))

test                tset
[1]中的
:s=“测试”

在[2]:print(“{0:那没用。整个语句都被破坏了。嗨,丹,你能建议一些更改,让我可以打印一些像monkey>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>的东西吗?
”*5
,如果有帮助的话。
In [1]: s = "test"
In [2]: print('{0:<20}{1}'.format(s,s[::-1]))

test                tset