手机
当前位置:查字典教程网 >脚本专栏 >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三元运算符实现方法

python读取注册表中值的方法

Python通过解析网页实现看报程序的方法

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

python实现系统状态监测和故障转移实例方法

python中stdout输出不缓存的设置方法

Python实例之wxpython中Frame使用方法

python中定义结构体的方法

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

精品推荐
分类导航