简体   繁体   中英

urllib.request.urlopen("ftp://username:password@ftpserver/file" returns <urlopen error [Errno -2] Name or service not known> if password contains '#'

urllib.request.urlopen("ftp://username:password@ftpserver/file" returns <urlopen error [Errno -2] Name or service not known> if password contains '#'

Could someone let me know if there are any known issues? or workaround or fix available for this

The requests library doesn't support ftp:// type links.

To download a file from an FTP server I would recommend using urlretrieve .

Try something like the following:

import urllib.request

urllib.request.urlretrieve('ftp://server/path/to/file', 'file')
# if you need to pass credentials try 
urllib.request.urlretrieve('ftp://username:password@server/path/to/file', 'file')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM