admin管理员组文章数量:1567278
代码实例
strs=(1,2,3,4) #创建一个集合
strs
(1, 2, 3,4)
>>> print 'strs= %s ' % strs
Traceback (most recent call last):
File "<pyshell#43>", line 1, in <module>
print 'strs= %s ' % str
TypeError: not all arguments converted during string formatting
原因:1 % 操作符只能直接用于字符串(‘123’),列表([1,2,3])、元组,因此需要一一匹配操作符。
如何解决
print 'strs= %s' % (strs,)
strs= (1, 2, 3,4)
也可以用:
print 'strs= %s,%s,%s,%s' % sstr
strs= 1,2,3,4
本文标签: 报错argumentsTypeErrorPythonformatting
版权声明:本文标题:Python TypeError: not all arguments converted during string formatting 报错 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1726224279a1061318.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论