如何在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
相關文章
相關標籤/搜索