python2 实现的LED大数字效果

#filename:bigNumber.py

zero=['*******','*     *','*     *','*     *','*     *','*     *','*******']

one=['      *','      *','      *','      *','      *','      *','      *']

two=['*******','      *','      *','*******','*      ','*      ','*******']

three=['*******','      *','      *','*******','      *','      *','*******']

four=['*     *','*     *','*     *','*******','      *','      *','      *']

five=['*******','*      ','*      ','*******','      *','      *','*******']

six=['*******','*      ','*      ','*******','*     *','*     *','*******']

seven=['*******','      *','      *','      *','      *','      *','      *']

eight=['*******','*     *','*     *','*******','*     *','*     *','*******']

nine=['*******','*     *','*     *','*******','      *','      *','*******']

 

numArr=[zero,one,two,three,four,five,six,seven,eight,nine]

 

while True:

    try:

        #input a number

        num = raw_input("Enter a number:")

        for i in range(0,7):

            line=''

            j=0

            while j<len(num):

                n=int(num[j])

                line+=numArr[n][i]+' ' 

                j+=1

            print line

    except ValueError as err:

        print err

输出效果:

Enter a number:2012

******* *******       * ******* 

      * *     *       *       * 

      * *     *       *       * 

******* *     *       * ******* 

*       *     *       * *       

*       *     *       * *       

******* *******       * ******* 

你可能感兴趣的:(python)