Electronic clock drawn by Python

Source: Internet
Author: User
Tags month name

First view (in Windows ):

The display is not refreshed in idle:

When I draw a number, I draw a line by line. Fortunately, it is very bitter.

The comment does not use Chinese characters, because running in Windows cmd may cause errors, so it does not matter in idle.

Time obtained:

Time. strftime ('% Y-% m-% d', time. localtime (Time. Time ()))

The format is as follows:

% Y two-digit year (00-99)
% Y indicates the four-digit year (000-9999)
% M month (01-12)
One day in % d month (0-31)
% H hour in 24-hour format (0-23)
% I 12-hour (01-12)
% M minutes (00 = 59)
% S seconds (00-59)

% A local simplified week name
% A local full week name
% B local simplified month name
% B local full month name
% C local Date and Time
% J one day in the year (001-366)
% P local equivalent of a. m. or P. M.
% U number of weeks in a year (00-53) Sunday is the start of the week
% W Week (0-6), Sunday is the beginning of the week
% W number of weeks in a year (00-53) Monday is the start of the week
% X local date Representation
% X Local Time Representation
% Z Current Time Zone name


Code (python2.5.4 ):

import timeimport os#print the num(0-9)def printline(line,num):    if line==1:        if num==1:            print '   # ',        if num==0 or num==2 or num==3 or num==5 or num==6 or num==7 or num==8 or num==9:            print '#### ',        if num==4:            print '#  # ',    if line==2:        if num==1:            print '   # ',        if num==2 or num==3 or num==7:            print '   # ',        if num==4 or num==8 or num==9 or num==0:            print '#  # ',        if num==5 or num==6:            print '#    ',    if line==3:        if num==1:            print '   # ',        if num==2 or num==3 or num==4 or num==5 or num==6 or num==8 or num==9:            print '#### ',        if num==7:            print '   # ',        if num==0:            print '#  # ',    if line==4:        if num==1:            print '   # ',        if num==2:            print '#    ',        if num==3 or num==4 or num==5 or num==7 or num==9:            print '   # ',        if num==6 or num==8 or num==0:            print '#  # ',    if line==5:        if num==1:            print '   # ',        if num==2 or num==3 or num==5 or num==6 or num==8 or num==9 or num==0:            print '#### ',        if num==4 or num==7:            print '   # ',#print the timedef printtime(hour,minute,second):    h=int(hour)    m=int(minute)    s=int(second)    hn=divmod(h,10)    mn=divmod(m,10)    sn=divmod(s,10)    #print hn        for i in range(1,6):        printline(i,hn[0])        printline(i,hn[1])        if i==2 or i==4:            print ' # ',        else:            print '   ',                    printline(i,mn[0])        printline(i,mn[1])        if i==2 or i==4:            print ' # ',        else:            print '   ',                    printline(i,sn[0])        printline(i,sn[1])        print ''        #get the local System times=time.strftime('%S',time.localtime(time.time()))jiange=int(raw_input("input the refresh time(second):"))while True:    hour=time.strftime('%H',time.localtime(time.time()))    minute=time.strftime('%M',time.localtime(time.time()))    second=time.strftime('%S',time.localtime(time.time()))    #print hour+":"+minute+":"+second        if int(second)-int(s)>=jiange:        os.system("cls")        printtime(hour,minute,second)        print '\n\n'        s=time.strftime('%S',time.localtime(time.time()))    

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.