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


基础教程推荐
- Kivy 使用 opencv.调整图像大小 2022-01-01
- 比较两个文本文件以找出差异并将它们输出到新的文本文件 2022-01-01
- Python,确定字符串是否应转换为 Int 或 Float 2022-01-01
- matplotlib 设置 yaxis 标签大小 2022-01-01
- 对多索引数据帧的列进行排序 2022-01-01
- 在 Python 中将货币解析为数字 2022-01-01
- kivy 应用程序中的一个简单网页作为小部件 2022-01-01
- 究竟什么是“容器"?在蟒蛇?(以及所有的 python 容器类型是什么?) 2022-01-01
- 在 Django Admin 中使用内联 OneToOneField 2022-01-01
- Python 中是否有任何支持将长字符串转储为块文字或折叠块的 yaml 库? 2022-01-01