Comment detail

条件を満たす行を取り除く (Nested Flatten)
何気にwith文。多分Python2.5以降限定。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
from __future__ import with_statement
import sys

def convert(input, output):
    with open(output, "w") as io:
        for line in open(input):
            if not line.startswith("#"):
                io.write(line)

if __name__ == '__main__':
    convert(sys.argv[1], sys.argv[2])

Index

Feed

Other

Link

Pathtraq

loading...