0
私は、PythonのV 2.7を持っています.11そして次のコードを使用してください。
formatter = "%r %r %r $r"
print formatter % (1, 2, 3, 4)
print formatter % ("one", "two", "three", "four")
print formatter % (True, False, False, True)
print formatter % (formatter, formatter, formatter, formatter)
print formatter % (
"I had this thing.",
"That you could type up right.",
"But it didn't sing.",
"So I said goodnight."
)
python ex8.pyを実行すると、このエラーが発生します。
Traceback (most recent call last):
File "ex8.py", line 3, in <module>
print formatter % (1, 2, 3, 4)
TypeError: not all arguments converted during string formatting
このコードでは何が問題になりますか?私が見るところでは、これはまさに本の中に書かれたものですが、私はエラーを受けています。
ご協力いただければ幸いです。
また、Pythonを学ぶのに役立つ他のリソースもありがとうございます。
'formatter ="%r%r%r%r "' - 最後に '%r'の代わりに' $ r'を書きました。 – poke