python 七段管模块

def drawGap(): #绘制数码管间隔
turtle.penup()
turtle.fd(5)
def drawLine(draw): #绘制单段数码管
drawGap()
turtle.pendown() if draw else turtle.penup()
turtle.fd(40)
drawGap()
turtle.right(90)
def drawDigit(d): #根据数字绘制七段数码管
drawLine(True) if d in [2,3,4,5,6,8,9] else drawLine(False)
drawLine(True) if d in [0,1,3,4,5,6,7,8,9] else drawLine(False)
drawLine(True) if d in [0,2,3,5,6,8,9] else drawLine(False)
drawLine(True) if d in [0,2,6,8] else drawLine(False)
turtle.left(90)
drawLine(True) if d in [0,4,5,6,8,9] else drawLine(False)
drawLine(True) if d in [0,2,3,5,6,7,8,9] else drawLine(False)
drawLine(True) if d in [0,1,2,3,4,7,8,9] else drawLine(False)
turtle.left(180)
turtle.penup()
turtle.fd(20)

实例

绘制时间

import turtle, time
t=turtle.Pen() <粘贴模板代码> def drawchinese(word):
t.sety(-55)
if word == '-':
t.write('年',font=("Arial", 70, "normal"))
t.fd(110)
elif word == '=':
t.write('月',font=("Arial", 70, "normal"))
t.fd(110)
elif word == '+':
t.write('日',font=("Arial", 70, "normal"))
t.sety(0) def drawDate(date):
for i in date:
if i=='-'or i=='='or i=='+':
drawchinese(i)
else:
drawDigit(eval(i))
def main():
turtle.setup(1000, 350, 200, 200)
t.penup()
t.forward(-450)
t.pensize(5)
drawDate(time.strftime('%Y-%m=%d+',time.gmtime()))
turtle.exitonclick()
main()

python 七段管模块的更多相关文章

  1. python之platform模块

    python之platform模块 ^_^第三个模块从天而降喽!! 函数列表 platform.system() 获取操作系统类型,windows.linux等 platform.platform() ...

  2. python之OS模块详解

    python之OS模块详解 ^_^,步入第二个模块世界----->OS 常见函数列表 os.sep:取代操作系统特定的路径分隔符 os.name:指示你正在使用的工作平台.比如对于Windows ...

  3. python之sys模块详解

    python之sys模块详解 sys模块功能多,我们这里介绍一些比较实用的功能,相信你会喜欢的,和我一起走进python的模块吧! sys模块的常见函数列表 sys.argv: 实现从程序外部向程序传 ...

  4. 学习PYTHON之路, DAY 6 - PYTHON 基础 6 (模块)

    一 安装,导入模块 安装: pip3 install 模块名称 导入: import module from module.xx.xx import xx from module.xx.xx impo ...

  5. linux下python调用c模块

    在C调用Python模块时需要初始化Python解释器,导入模块等,但Python调用C模块却比较简单,下面还是以helloWorld.c 和 main.py 做一说明:   (1)编写C代码,hel ...

  6. Python学习之模块进程函数详解

    今天在看<Beginning Linux Programming>中的进程相关部分,讲到Linux几个进程相关的系统函数: system , exec , fork ,wait . Pyt ...

  7. python基础——第三方模块

    python基础——第三方模块 在Python中,安装第三方模块,是通过包管理工具pip完成的.  如果你正在使用Mac或Linux,安装pip本身这个步骤就可以跳过了.  如果你正在使用Window ...

  8. python基础——使用模块

    python基础——使用模块 Python本身就内置了很多非常有用的模块,只要安装完毕,这些模块就可以立刻使用. 我们以内建的sys模块为例,编写一个hello的模块: #!/usr/bin/env ...

  9. python 中time模块使用

    在开始之前,首先要说明这几点: 1.在Python中,通常有这几种方式来表示时间:1)时间戳 2)格式化的时间字符串 3)元组(struct_time)共九个元素.由于Python的time模块实现主 ...

随机推荐

  1. __x__(28)0907第四天__固定布局

    布局 固定布局,需要计算单位 自适应响应布局  固定布局 html代码 <!doctype html> <html> <head> <meta charset ...

  2. (96)Wangdao.com_第二十九天_表单事件

    表单事件 input 事件        select 事件        change 事件        invalid 事件        reset 事件         submit 事件 ...

  3. maven入门概念及使用

    Maven 一.Maven概念 1.maven是什么:Maven 是一个项目管理工具.它负责管理项目开发过程中的几乎所有的东西. 版本.构建.输出物管理.依赖关系.文档和构建结果.项目关系.移植性管理 ...

  4. Oracle 触发器 trigger

    触发器: 当用户登录/退出或者操作某个数据对象或者进行DDL(建表,建view)引起某个储存过程的值的变化,把这个隐含被调用的过程,称为触发器. 语法 CREATE OR REPLACE TRIGGE ...

  5. css-不固定宽高定位

    position: fixed; top:50%; left: 50%; transform: translate(-50%, -50%);

  6. shell中,我们可以通过简单的一个判断来判断命令是否存在

    shell中,我们可以通过简单的一个判断来判断命令是否存在 which "Command" > /dev/null if [ $? -eq 0 ] then echo com ...

  7. Web Service学习(一)

    1.WebMethod特性包含哪些属性,都有什么用? 1.BufferResponse属性 该属性表明是否启用对Web Service方法响应的缓冲.当设置为true时,Web Service方法将响 ...

  8. SSIS - 1.简介

    一.什么是SSIS? 1)SSIS全称为Microsoft SQL Server Integration Services. 2)ETL全称为Extraction, Transformation an ...

  9. day 22 二十二、面向对象导入、名称空间、类与对象

    一.面向对象导入 1.含义: ①面向过程: 重过程:解决问题,考虑的是解决问题的流程 解决问题的思路清晰,但拓展性不强 ②面向对象: 重对象:解决问题,找到解决问题的对象 解决问题的思路可能不止一条( ...

  10. 一个RDBMS左连接SQL执行计划解析

    1.测试数据如下: SQL> select * from t1;  a | b  | c ---+----+---  1 | 10 | 1  2 | 20 | 2  3 | 30 | 3  4 ...