本文介紹了使用 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";錯誤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!