Accessing FTP server with Python fails with quot;getaddrinfoquot; error(使用 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";错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 Python 访问 FTP 服务器失败并显示“getaddrin


基础教程推荐
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 筛选NumPy数组 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01