String formatting error
问题 Using the code print('{0} is not'.format('That that is not')) in Python 3.1.1, I get the following error: AttributeError: 'str' object has no attribute 'format' when I delete the line Netbeans automatically inserted at the beginning: from distutils.command.bdist_dumb import format which itself causes an error of ImportError: cannot import name format What am I doing wrong here? 回答1: You must be running an older version of Python. This does work in Python 3.1.1+: $ python3 Python 3.1.1+ (r311