当前位置: 移动技术网 > IT编程>脚本编程>Python > Python2实现的LED大数字显示效果示例

Python2实现的LED大数字显示效果示例

2017年12月12日  | 移动技术网IT编程  | 我要评论

淮阴工学院天空教室,丢了西瓜捡芝麻,最好看的韩国古装剧

本文实例讲述了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

运行效果如下图:

更多Python相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》及《》

希望本文所述对大家Python程序设计有所帮助。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网