如何在python字符串中打印文字大括号字符并在其上使用.format?

问题:

x = " \{ Hello \} {0} "
print x.format(42)

gives me : Key Error: Hello\\\\ 给我: Key Error: Hello\\\\ python

I want to print the output: {Hello} 42 我要打印输出: {Hello} 42 curl


解决方案:

参考一: https://stackoom.com/question/Mw4Z/如何在python字符串中打印文字大括号字符并在其上使用-format
参考二: https://oldbug.net/q/Mw4Z/How-can-I-print-literal-curly-brace-characters-in-python-string-and-also-use-format-on-it
相关文章
相关标签/搜索