我试图用。format()插值方法编写一个代码,但是在打印STMT时得到了相同的错误。 下面是错误。 谢谢你的帮助。
1
2 txt1 = "My name is {}, I'm {}".format('john','12')
----> 3 print(txt1)
TypeError: 'str' object is not callable
使用另一种字符串格式化方式更容易,例如:
name = 'john'
age = 12
text = f"My name is {name}, I'm {12}"