Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to have this code do the following

  1. Ask the user which folder they want to download too.
  2. Down load the file from the FTP server to the selected file

but when ever I run the following code it just downloads/ writes the file to the local directory

how can I have the code write to the selected folder and not the local directory.

here is the code I am working with

root = tk.Tk()
root.withdraw()

FTP_HOST = HOST
FTP_USER = USER
FTP_PASS = PASS

down_load_path=fd.askdirectory()
ftp = ftplib.FTP(FTP_HOST, FTP_USER, FTP_PASS)



file_downloaded=ftp.retrbinary("RETR " + 'work out app outline1.txt', open('work out app outline1.txt', 'wb').write)
file_downloaded.write(down_load_path)

ftp.quit()
root.mainloop()

I keep getting error AttributeError: 'str' object has no attribute 'write'


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
454 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...