[英]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 '#' urllib.request.urlopen("ftp://username:password@ftpserver/file" 如果密码包含“#”,则返回 <urlopen 错误 [Errno -2] 名称或服务未知>
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. requests
库不支持ftp://
类型的链接。
To download a file from an FTP server I would recommend using urlretrieve
.要从 FTP 服务器下载文件,我建议使用
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')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.