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