【发布时间】:2019-07-10 10:22:10
【问题描述】:
我有点好奇为什么我的代码会导致此错误?
有人可以告诉我一些见解作为解决此问题的方法以及引发此错误的原因吗?
错误:
chunk += " " (16 - len(chunk) % 16)
TypeError: 'str' object is not callable
我的代码:
def upload(item):
with open(item, "rb") as fp:
while True:
chunk = fp.read(64*1024)
if len(chunk) == 0:
break
elif len(chunk) % 16 != 0:
chunk += " " (16 - len(chunk) % 16)
self.s.send(encrypt(self.key, chunk, self.iv))
self.s.send("DONE")
self.update()
【问题讨论】:
-
你忘记了
" "之后的* -
@OlivierMelançon 我在我的其他脚本中使用完全相同的代码并且它没有引发错误为什么它现在才这样做?
-
好吧,也许在你的其他脚本中永远不会到达错误行
标签: python string object callable