繁体   English   中英

TypeError: not all arguments converted during string formatting 错误 python

[英]TypeError: not all arguments converted during string formatting error python

我已经为我们的 REST API 定制了暴风雨代码,但是当我运行脚本时,在开始时使用 nosetests 它给出了一些奇怪的类型错误,如下所述,尽管脚本中的测试用例通过了

Traceback (most recent call last):
  File "/usr/lib64/python2.6/logging/__init__.py",line 776, in emit msg = self.format(record)
  File "/usr/lib64/python2.6/logging/__init__.py", line 654, in format return fmt.format(record)
  File "/home/rmcbuild/repository/rmc-test/tempest/openstack/common/log.py", line 516, in format return logging.Formatter.format(self, record)
  File "/usr/lib64/python2.6/logging/__init__.py", line 436, in format record.message = record.getMessage()
  File "/usr/lib64/python2.6/logging/__init__.py", line 306, in getMessage msg = msg % self.args
 TypeError: not all arguments converted during string formatting

有没有人遇到过这种类型的错误,如果有人帮助我解决这个问题,我将不胜感激。

谢谢,

使用%s打印字符串时会发生这种情况:

>>> x = 'aj8uppal'
>>> print 'Hello, %s %s' %(x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: not enough arguments for format string
>>> print 'Hello, ' %(x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: not all arguments converted during string formatting
>>> 

如果你放了太多的%s ,它会给出一个TypeError: not enough arguments for format string ,但如果你把一个放到少数,它会给出TypeError: not all arguments converted during string formatting

可能的是,您最后在括号中放置了一个变量,但百分号的数量不匹配。 如果您希望我们进一步帮助您,请发布您的代码:)

当我错误地输入了“&s”而不是“%s”时,我收到了这个错误

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM