开发者

File upload via FTP gaieerror Python 2.6

I'm trying to upload a text file to an FTP server, but I am getting this error:

gaierror: [Errno 1开发者_运维技巧1004] getaddrinfo failed

Here is my code.

        s = ftplib.FTP("ftp://xbrera.co.cc", "myuser", "mypass")
        f = open(path + "LD.txt", "r")
        s.storbinary("STOR " + path + "LD.txt")
        f.close()
        s.quit()

What am I doing wrong, and why am I getting this error? Thanks!


Change your code to s = ftplib.FTP("xbrera.co.cc", "myuser", "mypass"). The ftp:// is only mandatory for a URI but the ftplib library expect the hostname of your FTP server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜