本文實例講述了Python2實現(xiàn)的LED大數(shù)字顯示效果。分享給大家供大家參考,具體如下:
#filename:bigNumber.pyzero=['*******','* *','* *','* *','* *','* *','*******']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運行效果如下圖:

更多Python相關內(nèi)容感興趣的讀者可查看本站專題:《Python列表(list)操作技巧總結(jié)》、《Python編碼操作技巧總結(jié)》、《Python數(shù)據(jù)結(jié)構與算法教程》、《Python函數(shù)使用技巧總結(jié)》、《Python字符串操作技巧匯總》、《Python入門與進階經(jīng)典教程》及《Python文件與目錄操作技巧匯總》
希望本文所述對大家Python程序設計有所幫助。
新聞熱點
疑難解答