在使用FTP上传JSON文件时,我需要一些帮助,我尝试过阅读解决方案,但无法弄清楚。
我的代码如下所示:
ftp = FTP('xxx.xxx.x.xx','Uname','Pword')
ftp.cwd("/incoming")
file=open('C:/MyFile.json', 'rb')
ftp.storbinary('STOR MyFile.json','file')
运行此命令时,出现错误消息:
line 505, in storbinary
buf = fp.read(blocksize)
AttributeError: 'str' object has no attribute 'read'
ftp.storbinary
需要一个类似文件的打开对象,而不是字符串。您应该通过file
而不是'file'
(我认为这更多是错字)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句