Python学习笔记(三) -- Python FTP上传下载
来源:互联网 发布:淘宝上新宝贝教程视频 编辑:程序博客网 时间:2024/04/30 05:44
Python使用FTP上传下载
class FtpTools(): def _init_(self, host, user, passwd): self.ftp = ftplib.FTP() self.ftp.connect('host',21) self.ftp.login('logback', 'logback') def upLoad(self, srcFile, dstDir): try: #调试级别: 2-显示详细信息;0-关闭调试信息 ftp.set_debuglevel(2) #选择操作目录 #ftp.cwd('xxx/xxx/') file_handler = open(srcFile, 'rb') bufsize = 1024 self.ftp.storbinary("STOR %s" % os.path.basename(dstDir), file_handler, bufsize) ftp.set_debuglevel(0) file_handler.close() except Exception, e: return 'upLoad file[' + srcFile + '] to [' + dstDir +'] failed! result is: ' + str(e) return 0 def downLoad(self, srcFile, dstDir): try: #调试级别: 2-显示详细信息;0-关闭调试信息 ftp.set_debuglevel(2) #选择操作目录 #ftp.cwd('xxx/xxx/') file_handler = open(srcFile, 'rb') bufsize = 1024 self.ftp.storbinary("RETR %s" % os.path.basename(dstDir), file_handler, bufsize) ftp.set_debuglevel(0) file_handler.close() except Exception, e: return 'download file[' + srcFile + '] to [' + dstDir +'] failed! result is: ' + str(e) return 0 def quit(self): self.ftp.quit()
0 0
- Python学习笔记(三) -- Python FTP上传下载
- python连接ftp上传下载
- python实现ftp上传下载文件
- python 实现ftp上传下载文件
- python从FTP上传下载文件
- python学习笔记三
- python学习笔记三
- python学习笔记:三
- Python学习笔记三
- python学习笔记三
- python学习笔记三
- Python学习笔记(三)
- python学习笔记(三)
- Python学习笔记(三)
- Python学习笔记:三
- python->FTP上传下载文件
- python ftp上传下载文件,支持断点续传
- Python ftp操作之二-------上传下载
- kindeditor在线HTML编辑器
- pdf如何转换成word文档教程
- 通过系统签名使apk有系统权限
- [Leetcode 15, medium] 3 Sum
- node.js debug
- Python学习笔记(三) -- Python FTP上传下载
- 体验常成员函数
- Android Fragment学习总结
- bitwise constness与logical constness【EC++笔记】
- 一些人生小建议
- ORACLE-基础十六(Using Globalizatin Suppot)
- R Tutorial on Reading and Importing Excel Files into R
- python入门学习总结
- 地图框架