一:官方doc
http://docs.python.org/py3k/library/ftplib.html#ftplib.FTP.transfercmd
二:
What Is the STOR command?
The STORE (STOR) command is used by the client to tell the server to accept the data transferred via the data connection and to store the data as a file at the server site. If the file specified in the pathname exists at the server site, its contents are replaced by the data being transferred. A new file is created at the server site if the file specified in the pathname does not already exist.
三:
from ftplib import FTP
def upload():
ftp = FTP("localhost")
ftp.login("a", "a")
file = open("d:/1.jpg","rb")
ftp.storbinary("stor abc.jpg",file)
ftp.close()
def download():
ftp = FTP("localhost")
ftp.login("a", "a")
file = open("d:/download/d.jpg","wb")
ftp.retrbinary("retr abc.jpg", file.write)
ftp.close()
def list():
ftp = FTP("localhost")
ftp.login("a", "a")
ftp.dir()
ftp.close()
def delete():
ftp = FTP("localhost")
ftp.login("a", "a")
ftp.delete("icts.jpg")
ftp.close()
def rename():
ftp = FTP("localhost")
ftp.login("a", "a")
ftp.rename("icts.sql","new_icts.sql.bak")
ftp.close()
def mkdir():
ftp = FTP("localhost")
ftp.login("a", "a")
ftp.mkd("nagat")
ftp.close()
def rmdir():
ftp = FTP("localhost")
ftp.login("a", "a")
ftp.rmd("nagat")
ftp.close()
def pwd():
ftp = FTP("localhost")
ftp.login("a", "a")
ftp.pwd()
ftp.close()
def size():
ftp = FTP("localhost")
ftp.login("a", "a")
s = ftp.size("1.exe")
print(s)
ftp.close()
#download()
#delete()
#rename()
#mkdir()
#rmdir()
#pwd()
size()
#list()