我正在尝试从 ftp 下载特定文件,但在尝试连接时出现错误
import ftplib
url = 'ftp://ftp.ensemblgenomes.org/pub/release-41/bacteria//fasta/bacteria_176_collection/_bacillus_aminovorans/cdna/'
ftp = ftplib.FTP(url)
我得到的错误: UnicodeError: encoding with 'idna' codec failed (UnicodeError: label too long)
url = 'ftp://ftp.ensemblgenomes.org/pub/release-41/bacteria//fasta/bacteria_176_collection/_bacillus_aminovorans/cdna/'
ftp = ftplib.FTP(url)
class ftplib.FTP(host='', user='', passwd='', acct='', timeout=None, source_address=None)
返回 FTP 类的新实例。当给出主机时,调用 connect(host) 方法。
换句话说:第一个参数应该只是一个主机名,而不是一个带有protocol://host/path
. 如果要连接到服务器并使服务器更改为特定路径,则需要分步执行此操作:
ftp = ftplib.FTP('ftp.ensemblgenomes.org','ftp','[email protected]')
ftp.cwd('/pub/release-41/bacteria//fasta/bacteria_176_collection/_bacillus_aminovorans/cdna/')
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句