PythonでFTPに接続してPUTしてみる。
>>> f = open("C:\\tmp\\22.gif",'r') # ファイルを取得する
>>> from ftplib import FTP
>>> ftp = FTP("domain") # FTPで接続
>>> ftp.login("username","password") # login
>>> ftp.retrlines("LIST") # 一覧を取得
lrwxrwxrwx 1 0 0 31 Sep 17 2008 test
drwxr-xr-x 3 0 0 4096 Sep 17 2008 tmp
drwxrwxrwx 2 501 501 4096 Sep 01 2008 users
>>> ftp.cwd("/home/user/tmp") # 移動
>>> ftp.storbinary("STOR 22.gif", f) # put asciiの場合はftp.storlines
>>> ftp.close()
参考URL
http://kapi.jp/kapi_blog/229
2009年05月13日
関連カテゴリ Python