Skip to content

Instantly share code, notes, and snippets.

@ranlix
Last active December 17, 2015 09:08
Show Gist options
  • Save ranlix/5584695 to your computer and use it in GitHub Desktop.
Save ranlix/5584695 to your computer and use it in GitHub Desktop.
Created by Alex Li; Bell us when it's the whole point
# coding=gbk
import time
from datetime import datetime
LAST_MINUTE = 59 #when it is the last mintue in an hour,the minute is (60-1)
MINUTE_SECONDS = 60#one minute has 60s
def main():
'''This is a main function to print bell when time is the whole point.'''
if time.localtime().tm_min == LAST_MINUTE:
# when the minute is 59, the sleep time is not 60s any more
time.sleep(MINUTE_SECONDS-time.localtime().tm_sec)
print "dang!"*int(datetime.now().strftime("%I")) + '\n'
else:
time.sleep(MINUTE_SECONDS)
while 1:
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment