开发者

File upload via FTP gaieerror Python 2.6

开发者 https://www.devze.com 2023-02-13 14:13 出处:网络
I\'m trying to upload a text file to an FTP server, but I am getting this error: gaierror: [Errno 1开发者_运维技巧1004] getaddrinfo failed

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

精彩评论

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