Last Updated: February 25, 2016
·
596
· terukizm

lazy count string by python


!/usr/bin/python

import sys

argvs = sys.argv

if len(argvs) != 2:
print ' usage: $python %s [filename]' % argvs[0]
sys.exit(1)

line = ""
buffsize = 1024 * 1024 * 1024 # 1GB buffer
while True:
buff = f.read(buffsize)
line += buff
if len(buff) != buffsize:
break

print ' line is %s . ' % line.count('[#@@@@#]')
</pre>