這篇文章主要介紹了Python2實現的LED大數字顯示效果,涉及Python的簡單交互與列表相關使用技巧,需要的朋友可以參考下
本文實例講述了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
運行效果如下圖:
以上是使用Python2完成LED顯示大數字的效果實例的詳細內容。更多資訊請關注PHP中文網其他相關文章!