我收到以下错误,我该如何解决?
KeyError:'a'过程以退出代码1结束
s = """
a b c {a}
""".format({'a':'123'})
print s
Run Code Online (Sandbox Code Playgroud)
您需要按名称传递参数.format(a=123)或使用format_map需要字典的参数:
s = """
a b c {a}
""".format_map({'a':'123'})
Run Code Online (Sandbox Code Playgroud)