使用 Python 访问 FTP 服务器失败并显示“getaddrinfo";错误

Accessing FTP server with Python fails with quot;getaddrinfoquot; error(使用 Python 访问 FTP 服务器失败并显示“getaddrinfo;错误)
本文介绍了使用 Python 访问 FTP 服务器失败并显示“getaddrinfo";错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在尝试访问开放的 DLP 测试 FTP 服务器作为练习.我不断收到 getaddrinfo 错误,但我不确定哪里出错了.我在 Windows 10 上使用 Python 2,并且已经检查过我没有使用代理.

I am trying to access the open DLP Test FTP server as a practice. I keep getting a getaddrinfo error but I am unsure of where I'm going wrong. I am using Python 2 on a Windows 10, and have already checked that I am not behind a proxy.

代码:

from ftplib import FTP
ftp = FTP('ftp://ftp.dlptest.com/')
...

错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:Python27libftplib.py", line 120, in __init__
    self.connect(host)
  File "C:Python27libftplib.py", line 135, in connect
    self.sock = socket.create_connection((self.host, self.port), self.timeout)
  File "C:Python27libsocket.py", line 553, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 11001] getaddrinfo failed

感谢任何帮助!

推荐答案

使用

ftp = FTP('ftp.dlptest.com')

改为.

FTP 构造函数的第一个参数 是 host - 主机名IP 地址 - 不是 URL.

The first argument of FTP constructor is host – a hostname or an IP address – not a URL.

这篇关于使用 Python 访问 FTP 服务器失败并显示“getaddrinfo";错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)