1. FTP Library
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | from ftplib import FTP class pyftp(): def __init__(self,host,user,passwd): self.ftp = FTP(host) # connect to host, default port self.ftp.login(user,passwd) def close(self): return self.ftp.quit() def pasv(self): return self.ftp.set_pasv(True) def cd(self,path): return self.ftp.cwd(path) def ls(self): return self.ftp.retrlines('LIST') def get(self,remote,local): return self.ftp.retrbinary('RETR ' + remote, open(local, 'wb').write) def put(self,local,remote): return self.ftp.storbinary('STOR ' + remote, open(local, 'rb')) |
2. FTP Library Test Example
1 2 3 4 5 6 | def ftpTest(): ftp = pyftp(sys.argv[1],sys.argv[2],sys.argv[3]) ftp.pasv() print(ftp.ls()) print(ftp.get("a.c","D:/Temp/aaaa.c")) print(ftp.put("D:/Temp/aaaa.c","bbbb.c")) |
댓글 없음:
댓글 쓰기