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:
breakprint ' line is %s . ' % line.count('[#@@@@#]')
</pre>
Written by KOIZUMI teruaki
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Related Tags
#python
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#