本文介紹了使用 Python 訪問(wèn) FTP 服務(wù)器失敗并顯示“getaddrinfo";錯(cuò)誤的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
我正在嘗試訪問(wèn)開(kāi)放的 DLP 測(cè)試 FTP 服務(wù)器作為練習(xí).我不斷收到 getaddrinfo 錯(cuò)誤,但我不確定哪里出錯(cuò)了.我在 Windows 10 上使用 Python 2,并且已經(jīng)檢查過(guò)我沒(méi)有使用代理.
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/')
...
錯(cuò)誤:
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
構(gòu)造函數(shù)的第一個(gè)參數(shù) 是 host
- 主機(jī)名 或 IP 地址 - 不是 URL.
The first argument of FTP
constructor is host
– a hostname or an IP address – not a URL.
這篇關(guān)于使用 Python 訪問(wèn) FTP 服務(wù)器失敗并顯示“getaddrinfo";錯(cuò)誤的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!