Skip to content

Instantly share code, notes, and snippets.

@bluven
Created March 28, 2012 09:03
Show Gist options
  • Save bluven/2224927 to your computer and use it in GitHub Desktop.
Save bluven/2224927 to your computer and use it in GitHub Desktop.
在给定的时间里计数
#!/usr/bin/python
# coding:utf-8
from time import time
def loop_in_sec(duration = 1):
start = time()
count = 1
while (time() - start) < duration:
yield count
count += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment