On Jul 28, 2:27 pm, "Harry" <[EMAIL PROTECTED]> wrote:
> Hi there. I am trying to download a file(sn.last) from a public FTP
> server with the following code:
>
> from ftplib import FTP
> ftp=FTP('tgftp.nws.noaa.gov')
> ftp.login()
> ftp.cwd('SL.us008001/DF.of/DC.radar/DS.81dpr/SI.kbuf')
> ftp.retrbinar('RETR sn.last', open(mydpa,'wb').write)

open(mydpa,'wb') would open the file to which you're saving the data,
but you haven't defined to mydpa, so Python will complain.

> ftp.quit()
>
> but got an error message, which I think is normal:
>
> Traceback (most recent call last):
>   File "<pyshell#13>", line 1, in <module>
>     ftp.retrbinary('RETR sn.last', open(mydpa,'wb').write)
> NameError: name 'mydpa' is not defined

Yep!

>
> I don't know much about python, but just try to use the code to
> download data. I don't know where the file will be saved to. Is the
> mydata a file name or a folder name? where will it be saved to even
> if it's working? Please help be fixed the problem step by step? I am
> using 2.5.2 by the way.
>

You need to tell it where to save the data by defining mydpa.

> I really appreciate your help. Thanks.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to