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

yipeiwu_com6年前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

运行效果如下图:

更多Python相关内容感兴趣的读者可查看本站专题:《Python列表(list)操作技巧总结》、《Python编码操作技巧总结》、《Python数据结构与算法教程》、《Python函数使用技巧总结》、《Python字符串操作技巧汇总》、《Python入门与进阶经典教程》及《Python文件与目录操作技巧汇总

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

相关文章

使用Python的Zato发送AMQP消息的教程

使用Python的Zato发送AMQP消息的教程

本 帮助主题 展示了使用Zato发送AMQP消息 所 需的内容. Zato 基于Python 的 为 SOA 、 云 集成 和 后端 服务 的 企业服务总线(ESB) 。 代码演示 下面...

举例讲解Python中的身份运算符的使用方法

举例讲解Python中的身份运算符的使用方法

Python身份运算符 身份运算符用于比较两个对象的存储单元 以下实例演示了Python所有身份运算符的操作: #!/usr/bin/python a = 20 b = 20...

使用Python制作获取网站目录的图形化程序

1.pyqt4写的界面 find_ui.py #-*- coding: utf-8 -*- from PyQt4 import QtCore, QtGui try: _fr...

python实现倒计时的示例

复制代码 代码如下:import timecount = 0 a = input('time:') b = a * 60 while (count <...

Python2与python3中 for 循环语句基础与实例分析

Python2与python3中 for 循环语句基础与实例分析

下面的代码中python2与python3的print使用区别,大家注意一下。python3需要加()才行。 语法: for循环的语法格式如下: for iterating_var...