我是一名新手程序员,刚开始学习Python 3。我阅读了《笨办法学Python》这本书,目前我遇到了以下代码:
x = "There are %d types of people." % 10
binary = "binary"
do_not = "don't"
y = "Those who know %s and those who %s" % (binary, do_not)
print(x)
print(y)
print("I said: %r") % x
我不太了解
%r
,%s
和%d
之间的区别。我收到的错误是TypeError: unsupported operand type(s) for %: 'NoneType' and 'str'
。我不知道该怎么做和如何修复它。请解释一下如何使其正常工作以及为什么它不能工作。另外,%r、%d和%s有什么区别?有没有有用的链接?非常感谢。