Python ftplib connection error (gaierror)

前端 未结 2 592
你的背包
你的背包 2020-12-20 14:20

I am trying to make a very basic FTP client in python, and within the first few lines of code I have already run into a problem

My Code:

from ftplib          


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-20 14:52

    I found myself here with this error trying to connect using the full path rather than just the hostname. Make sure you split that out and use cwd(path) after login().

    For example:

    ftp = FTP('ftp.ncdc.noaa.gov')
    ftp.login()
    ftp.cwd('pub/data/noaa/2013')
    

    instead of:

    # Doesn't work!!
    ftp = FTP('ftp.ncdc.noaa.gov/pub/data/noaa')
    ftp.login()
    ftp.cwd('2013')
    

    Kind of obvious in hindsight, but hopefully I help you notice your simple mistake!

提交回复
热议问题