0
我正嘗試下載並上傳到FTP服務器。下載工作得很好,但上載吐出這個錯誤:ftp.storbinary與ftp.retrbinary不一樣嗎?
錯誤:AttributeError的(「‘功能’對象有沒有屬性‘讀’」)
def download_handle(block):
global sizeWritten
dFile.write(block)
os.system('CLS')
sizeWritten += len(block)
percentComplete = sizeWritten/totalSize
percentComplete = round((percentComplete*100),1)
print (percentComplete, "% complete")
try:
dFile = open('filename', "wb")
print("DL File opened")
ftp.retrbinary("RETR " + filename, download_handle)
print("Download Completed")
dFile.close()
except Exception as e:
print("Error:", repr(e))
def upload_handle(block):
global sizeWritten
upFile.write(block)
os.system('CLS')
percentComplete = sizeWritten/totalSize
percentComplete = round((percentComplete*100),1)
print (percentComplete, "% complete")
try:
upFile = open('filename', "rb")
print("UL File opened")
ftp.storbinary("STOR " + filename, upload_handle)
print ("Upload completed")
upFile.close()
except Exception as e:
print("Error:", repr(e))
你永遠不會分配'download_handle',或者就此而言,'upload_handle'。請發佈*工作*代碼。 – kindall