忘忧草001
发表于 2016-12-21 23:23:11
不错
dodobar
发表于 2016-12-23 13:42:03
本帖最后由 dodobar 于 2016-12-23 13:43 编辑
dict1={0:[' _','| | ','|_| '],\
1:[' ','| ','| '],\
2:[' _',' _| ','|_'],\
3:[' _',' _| ',' _| '],\
4:[' ','|_| ','| '],\
5:[' _','|_',' _| '],\
6:[' _','|_','|_| '],\
7:[' _','| ','| '],\
8:[' _','|_| ','|_| '],\
9:[' _','|_| ',' _| ']}
number = input('请输入一串数字:')
for i in range(3):
for n in list(number):
print(dict1,end = ' ')
print()
sd小舅子
发表于 2016-12-25 23:35:35
本帖最后由 sd小舅子 于 2016-12-25 23:38 编辑
lcd = {0:[' _ ','| |','|_|'],
1:[' ','|','|'],
2:[' _ ',' _|','|_ '],
3:[' _ ',' _|',' _|'],
4:[' ','|_|','|'],
5:[' _ ','|_ ',' _|'],
6:[' _ ','|_ ','|_|'],
7:[' _ ','|','|'],
8:[' _ ','|_|','|_|'],
9:[' _ ','|_|',' _|']}
num = input('请输入数字:')
while True:
if num.isdigit():
break
else:
num = input('输入有误,请重新输入:')
for i in range(3):
for each in num:
print(lcd,end = '')
print()
黯然矢涩
发表于 2016-12-26 11:19:24
厉害啊
飘渺463431810
发表于 2017-1-12 09:35:02
新手还得认真学习了
蛋炒饭妖妖
发表于 2017-1-12 10:26:01
这样字典会不会看起来比较烦?
是不是可以直接用文件把数字的LED存储下来,需要的时候直接读
代码看起来简洁一点
jerryxjr1220
发表于 2017-1-12 10:29:33
蛋炒饭妖妖 发表于 2017-1-12 10:26
这样字典会不会看起来比较烦?
是不是可以直接用文件把数字的LED存储下来,需要的时候直接读
代码看起来 ...
当然可以,程序怎么写都可以
可以实现最后的结果,代码看起来简洁,就是目标
蛋炒饭妖妖
发表于 2017-1-12 10:31:13
jerryxjr1220 发表于 2017-1-12 10:29
当然可以,程序怎么写都可以
可以实现最后的结果,代码看起来简洁,就是目标
同意~~~
jerryxjr1220
发表于 2017-1-12 11:03:03
本帖最后由 jerryxjr1220 于 2017-1-12 11:10 编辑
蛋炒饭妖妖 发表于 2017-1-12 10:31
同意~~~
不过其实用个列表也很简洁的
pdic = [' _| | |_| ',' | | ',' _ _| |_',' _ _|_| ',' |_| | ',
' _|_ _| ',' _|_|_| ',' _ | | ',' _|_| |_| ',' _|_|_| ']
temp = input('Input the number:')
s = ['','','']
for i in temp:
for j in range(3):
s += pdic
print ('\n'.join(s))
AnlakHui
发表于 2017-1-12 23:26:29
来交作业了,感谢老师分享
jll421740865
发表于 2017-1-18 10:47:39
厉害了 经典的 题目
jll421740865
发表于 2017-1-18 10:48:26
看到过。。
Kiopler
发表于 2017-2-8 15:54:37
while True:
a = input(r'input the numbers:')
numdict = {
0:[' _ ','| |','|_|'],
1:[' ',' | ',' | '],
2:[' _ ',' _|','|_ '],
3:[' _ ',' _|',' _|'],
4:[' ','|_|','|'],
5:[' _ ','|_ ',' _|'],
6:[' _ ','|_ ','|_|'],
7:[' _ ','|','|'],
8:[' _ ','|_|','|_|'],
9:[' _ ','|_|',' _|']
}
show = ['','','']
for each in a:
each = int(each)
for i in range(3):
show += numdict
for each in show:
print(each)
"""
_ __ _ __ _ _
| ||_| _| |_| |_|_ | |_| |_|
|_|| |__| |_| |_|| |_|_|
"""
我是新人...{:10_266:} ,开始做楼主的每日一练啦,向楼主学习
这个题昨天看到的...一上来根本不会做{:10_247:}看了楼主的答案 然后今天独立打出来的
感觉学到了!感谢楼主{:10_266:}
yuzai1702
发表于 2017-2-9 13:08:12
0123就不行
余欲渔
发表于 2017-2-9 13:26:03
看了这里面的其他代码,觉得简洁又比我这个效率高,多做做练习能学到很多啊
def shu():
while True:
shuru=input('请输入需要转变的数字,输入0000结束:')
if shuru.isdigit():
return shuru
else:
print('输入有误,请重新输入!!!')
shu()
def xianshi(shuru):
s=[]
z=[]
x=[]
l=len(shuru)
for i in range(l):
if shuru=='0':
s+=[' ','_',' ',' ']
z+=['|',' ','|',' ']
x+=['|','_','|',' ']
elif shuru=='1':
s+=[' ',' ',' ',' ']
z+=[' ','|',' ',' ']
x+=[' ','|',' ',' ']
elif shuru=='2':
s+=[' ','_','_',' ']
z+=[' ','_','|',' ']
x+=['|','_',' ',' ']
elif shuru=='3':
s+=[' ','_',' ',' ']
z+=[' ','_','|',' ']
x+=[' ','_','|',' ']
elif shuru=='4':
s+=[' ',' ',' ',' ']
z+=['|','_','|',' ']
x+=[' ',' ','|',' ']
elif shuru=='5':
s+=[' ','_',' ',' ']
z+=['|','_',' ',' ']
x+=[' ','_','|',' ']
elif shuru=='6':
s+=[' ','_',' ',' ']
z+=['|','_',' ',' ']
x+=['|','_','|',' ']
elif shuru=='7':
s+=[' ','_',' ',' ']
z+=[' ',' ','|',' ']
x+=[' ','_','|',' ']
elif shuru=='8':
s+=[' ','_',' ',' ']
z+=['|','_','|',' ']
x+=['|','_','|',' ']
elif shuru=='9':
s+=[' ','_',' ',' ']
z+=['|','_','|',' ']
x+=[' ','_','|',' ']
for i in s:
print(i,end='')
print(' ')
for i in z:
print(i,end='')
print(' ')
for i in x:
print(i,end='')
print('\n')
while True:
shuru=shu()
if shuru=='0000':
exit()
else:
xianshi(list(shuru))
k950328
发表于 2017-2-10 14:49:35
学习一下!!!!!!!!!
zealstar
发表于 2017-2-12 14:02:11
本帖最后由 zealstar 于 2017-2-12 14:07 编辑
python看到第10集,还在学习,编了如下代码:
我的LCD构成貌似和楼主不一样……主要是自己想多了……{:10_266:}
def print_num(num_list):
if num_list == []:
return
count = 0
for i in num_list:
if i in ['0','2','3','5','6','7','8','9']:
print(" -- ", end='\t')
elif i in ['1','4']:
print(" ", end='\t')
if count >= 9:
break
count += 1
if count < 9:
print('')
count = 0
for i in num_list:
if i in ['0','4','8','9']:
print("||", end='\t')
elif i in ['1']:
print(" |", end='\t')
elif i in ['2','3','7']:
print(" |", end='\t')
elif i in ['5','6']:
print("| ", end='\t')
if count >= 9:
break
count += 1
if count < 9:
print('')
count = 0
for i in num_list:
if i in ['0','1','7']:
print(" ", end='\t')
elif i in ['2','3','4','5','6','8','9']:
print(" -- ", end='\t')
if count >= 9:
break
count += 1
if count < 9:
print('')
count = 0
for i in num_list:
if i in ['0','6','8']:
print("||", end='\t')
elif i in ['1']:
print(" |", end='\t')
elif i in ['2']:
print("| ", end='\t')
elif i in ['3','4','5','7','9']:
print(" |", end='\t')
if count >= 9:
break
count += 1
if count < 9:
print('')
count = 0
for i in num_list:
if i in ['0','2','3','5','6','8','9']:
print(" -- ", end='\t')
elif i in ['1','4','7']:
print(" ", end='\t')
if count >= 9:
break
count += 1
if count < 9:
print('')
else:
print_num(num_list[(count+1):])
number = input("请输入一串数字:")
while not (number.isdigit()):
print("输入非法,请重新输入!")
number = input("请输入一串数字:")
print_num(list(number))
执行结果:
727749815
发表于 2017-2-12 22:15:09
我来贴一下代码LCD=['|','__','|','',' ']
P1=[,,,,,,,,,]
P2=[,,,,,,,,,]
P3=[,,,,,,,,,]
a=input("Please input the number:")
for each_num in a:
i=int(each_num)
for j in P1:
print("%s"%(LCD),end='')
print("",end='')
print()
for each_num in a:
i=int(each_num)
for j in P2:
print("%s"%(LCD),end='')
print("",end='')
print()
for each_num in a:
i=int(each_num)
for j in P3:
print("%s"%(LCD),end='')
print("",end='')
零度非安全
发表于 2017-2-23 18:02:02
lcd_number = { 0:[' _ ','| |','|_|'],\
1:[' ','|','|'],\
2:[' _ ',' _|','|_ '],\
3:[' _ ',' _|',' _|'],\
4:[' ','|_|','|'],\
5:[' _ ','|_ ',' _|'],\
6:[' _ ','|_ ','|_|'],\
7:[' _ ','|','|'],\
8:[' _ ','|_|','|_|'],\
9:[' _ ','|_|',' _|'] }
while True:
input_number = input('Input the numbers:')
for i in range(3):
for j in input_number:
print(lcd_number,end = ' ')
print('')
solomonxian
发表于 2017-3-22 21:22:51
本帖最后由 solomonxian 于 2017-3-22 21:53 编辑
def ledNum(number):
"""使传入的数字变成LED显示的模样打印出来"""
s = """
_ __ _____
| | |_| _||_||_ |_ ||_||_|
|_| | |__|| _||_|||_| _|"""
num = str(number)
if not num.isdigit():
return print("请输入数字")
s_num = 1
# 只有3*n,不要怕嵌套循环
for i in range(3):
for j in num:
n = int(j)*3 + s_num
print(s, end="")
print("")
s_num += 31