手机
当前位置:查字典教程网 >脚本专栏 >python >python通过定义一个类实例作为ftp回调方法
python通过定义一个类实例作为ftp回调方法
摘要:本文实例讲述了python通过定义一个类实例作为ftp回调方法。分享给大家供大家参考。具体实现方法如下:classWriter:def__i...

本文实例讲述了python通过定义一个类实例作为ftp回调方法。分享给大家供大家参考。具体实现方法如下:

class Writer: def __init__(self, file): self.f = open(file, "w") def __call__(self, data): self.f.write(data) self.f.write('n') print data FILENAME = "AutoIndent.py" writer = Writer(FILENAME) import ftplib ftp = ftplib.FTP('127.0.0.1', 'book', 'bookpw') ftp.retrlines("RETR %s" % FILENAME, writer)

希望本文所述对大家的Python程序设计有所帮助。

【python通过定义一个类实例作为ftp回调方法】相关文章:

python解析json实例方法

python中的yield使用方法

python迭代器的使用方法实例

python逐行读取文件内容的三种方法

python批量下载图片的三种方法

python函数返回多个值的示例方法

Python实例之wxpython中Frame使用方法

python 不关闭控制台的实现方法

使用wxpython实现的一个简单图片浏览器实例

python回调函数的使用方法

精品推荐
分类导航