有很多条目,根据:"TypeError: not all arguments converted during string formatting"但我没有找到原因,为什么会这样:
print("File: %30s "%("name"))
正在工作,但不是这个:
leng=30
print("File: %"+ str(leng) +"s "%("name"))
最佳答案
由于操作顺序,您的代码评估为:
"File: %" + str(leng) + ("s "%("name"))
要解决此问题,只需将字符串括起来,如:
("File" + ...)%("name")
关于python格式字符串TypeError : not all arguments converted during string formatting,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47594101/