xto*_*ofl 2 python stdin pipe line-by-line
我试图在python中创建逐行过滤器.但是,stdin.readlines()在开始处理之前读取所有行,并且python耗尽内存(MemoryError).
我怎样才能一次在内存中只有一行?
我有这样的代码:
for line in sys.stdin.readlines():
if( filter.apply( line ) ):
print( line )
Run Code Online (Sandbox Code Playgroud)
(注意:我在2.6)
| 归档时间: |
|
| 查看次数: |
7758 次 |
| 最近记录: |