需要使用{{
或者}}
代替原本的{
或者}
举例如下
例子1
正常的format语句
print("{}".format(100))
例子2 想要通过正常方式输出{
或者}
会报错
print("{} and want to print another {hhh}".format(100))
例子3 使用正确的方法进行输出
print("{} and want to print another {{hhh}}".format(100))
例子4 在没有format的语句中使用双大括号就会正常打出两个大括号
print(str(100) + " and want to print another {{hhh}}")