Skip to content

Instantly share code, notes, and snippets.

@luistung
Created May 22, 2014 07:18
Show Gist options
  • Save luistung/ebcf5e69ba0897f1c8f4 to your computer and use it in GitHub Desktop.
Save luistung/ebcf5e69ba0897f1c8f4 to your computer and use it in GitHub Desktop.
python全局计数器
def counter(interval):
if not hasattr(counter,'count'):
counter.count = 0
counter.count += 1
import sys
if counter.count % interval == 0: print >>sys.stderr, counter.count
@luistung
Copy link
Author

用于记录文件已处理行数,每隔interval输出一次

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment