0
我正在通过Mathew Driscoll的“Python 101”工作,并在尝试此操作时遇到了问题。新的字符串格式化方法
>>> print("%(lang)s is fun!" % {"lang":"python"})
我明白我想要使用Python字典这里与郎是一个“键值对” 我做的是什么复制在书,但书已经出来了一段时间,我使用最新版本的Python。
这是错误我得到:
Traceback (most recent call last):
File "<pyshell#78>", line 1, in <module>
print("%(lang)s is fun!" % {"lang":"python"})
TypeError: 'str' object is not callable
您可能还需要寻找到'格式()'和[格式化语言(https://docs.python.org/3.5/library/string.html#formatspec),又名新样式字符串格式化是旨在取代传统的'%'方法。 – AChampion