首页 > 代码库 > Python 一日一练: 01

Python 一日一练: 01

 将数字转换为LCD模式

技术分享

 

代码如下:

技术分享
 1 # -*- coding:utf-8 -*-
 2 ‘‘‘
 3 Python 小练习-1 : 将数字转换为LCD显示
 4 ‘‘‘
 5 lt = [ __ , |__ , |__|,    |,  __|, |  |,     ]
 6 dt = {0:[0, 5, 2],1:[6, 3, 3], 2:[0, 4, 1], 3:[0, 4, 4], 4:[6, 2, 3], 5:[0, 1, 4], 6:[0, 1, 2], 7:[0, 3, 3], 8:[0, 2, 2], 9:[0, 2, 4]}
 7 
 8 data =http://www.mamicode.com/ input()
 9 for i in range(3):
10     for j in data:
11         print(lt[dt[int(j)][i]], end=  )
12     print(‘‘)
View Code

 

Python 一日一练: 01