小编use*_*591的帖子

TypeError:%支持的操作数类型:'NoneType'和'str'

所以我对编程非常陌生,我从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
Run Code Online (Sandbox Code Playgroud)

我真的不知道之间的区别%r,%s%d.我得到的错误是TypeError: unsupported operand type(s) for %: 'NoneType' and 'str'不知道该怎么做以及如何解决它.请解释我如何才能真正使它工作以及为什么它不起作用.另外,%r,d和s之间有什么区别?任何有用的链接?先感谢您.

python string-formatting typeerror

24
推荐指数
2
解决办法
6万
查看次数

标签 统计

python ×1

string-formatting ×1

typeerror ×1