需要使用{{或者}} 代替原本的{或者}
举例如下
例子1
正常的format语句
print("{}".format(100))
- 1
![]()
例子2 想要通过正常方式输出{或者}会报错
print("{} and want to print another {hhh}".format(100))
- 1
![]()
例子3 使用正确的方法进行输出
print("{} and want to print another {{hhh}}".format(100))
- 1
![]()
例子4 在没有format的语句中使用双大括号就会正常打出两个大括号
print(str(100) + " and want to print another {{hhh}}")
- 1
![]()
文章知识点与官方知识档案匹配,可进一步学习相关知识
Python入门技能树首页概览416632 人正在系统学习中
评论记录:
回复评论: