【问题标题】:What do brackets do to cause "TypeError: not all arguments converted during string formatting"?方括号会导致“TypeError:字符串格式化期间并非所有参数都转换”?
【发布时间】:2022-07-24 04:54:54
【问题描述】:

第一个代码运行正确,但第二个代码运行不正确。这里有什么问题?

>>> print("%d" %100,100)
100 100
>>> print("%d" %(100,100))
Traceback (most recent call last):
  File "<pyshell#96>", line 1, in <module>
    print("%d" %(100,100))
TypeError: not all arguments converted during string formatting

【问题讨论】:

  • 欢迎来到 SO。 print("%d" % (100, 100)) 期望你有两个参数.. 像 %d %d 的打印格式。

标签: python


【解决方案1】:

改变这一行

print("%d" %(100,100))

print("%d" %100,100)

它会解决你的问题。 谢谢。

【讨论】:

    猜你喜欢
    • 2020-08-23
    • 2015-10-28
    • 2015-01-21
    • 2013-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多