/ command

[Python]read all *.txt by command line

Sometimes, we'd like to process some file (like *.txt), maybe parsing, segmentation, and so on. And Python specialized in string process.

import os
f = os.popen("ls *.txt")
files = f.readlines()
f.close()
print len(files)
for f in files:
    print f

It's reference from here.