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
基础教程推荐
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 求两个直方图的卷积 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 包装空间模型 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
