我正在学习Python和我尝试使用的Python的FTPLIB模块使用此代码:
import ftplib
connect = ftplib.FTP('ftp://www.website.com')
connect.login = ('username', 'password')
data = []
connect.dir(data.append)
connect.quit()
for line in data:
print line
(我知道,这家网站,用户名和密码不正确,我用我的网站数据,我不想分享)我运行代码后收到以下错误:
Traceback (most recent call last):
File "ftp.py", line 3, in <module>
ftp = FTP('ftp://www.website.com') # connect to host, default port
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ftplib.py", line 120, in __init__
self.connect(host)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ftplib.py", line 135, in connect
self.sock = socket.create_connection((self.host, self.port), self.timeout)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
只是为了澄清,我正在使用Python 2.7在Mac上。 我不觉得有什么了细节,我可以分享。 谢谢您的帮助!