draw present time——画出当前时间

1月以前  |  阅读数:25 次  |     收藏

import turtle,time
import random

def drawLine(draw):
    colors = ['red','black', 'green', 'blue', 'yellow', 'purple','mauve','scarlet']
    a=random.randint(1,8)
    turtle.pencolor(colors[8%a])
    turtle.penup()
    turtle.fd(5)
    turtle.pendown() if draw else turtle.penup()
    turtle.fd(35)
    turtle.penup()
    turtle.fd(5)
    turtle.right(90)

def drawDigts(n):
    drawLine(True) if n in ['2', '3', '4', '5', '6', '8', '9'] else drawLine(False)
    drawLine(True) if n in ['0', '1', '3', '4', '5', '6', '7', '8', '9'] else drawLine(False)
    drawLine(True) if n in ['0', '2', '3', '5', '6', '8', '9'] else drawLine(False)
    drawLine(True) if n in ['0', '2', '6', '8'] else drawLine(False)
    turtle.left(90)
    drawLine(True) if n in ['0', '4', '5', '6', '8', '9'] else drawLine(False)
    drawLine(True) if n in ['0', '2', '3', '5', '6', '7', '8', '9'] else drawLine(False)
    drawLine(True) if n in ['0', '1', '2', '3', '4', '7', '8', '9'] else drawLine(False)
    turtle.left(180)
    turtle.penup()
    turtle.fd(10)

def drawDate(date):
    for i in range(0,len(date)):
        drawDigts(date[i])
        if date[i]=='-':
            turtle.penup()
            turtle.right(90)
            turtle.fd(30)
            turtle.left(90)
            turtle.pendown()
            turtle.write('年',align='center',font=('Arial',52,'normal',))
            turtle.penup()
            turtle.left(90)
            turtle.fd(30)
            turtle.right(90)
            turtle.fd(60)
        elif date[i]=='+':
            turtle.penup()
            turtle.right(90)
            turtle.fd(30)
            turtle.left(90)
            turtle.pendown()
            turtle.write('月',font=('Arial',52,'normal'))
            turtle.penup()
            turtle.left(90)
            turtle.fd(30)
            turtle.right(90)
            turtle.fd(60)
        elif date[i]=='=':
            turtle.penup()
            turtle.right(90)
            turtle.fd(30)
            turtle.left(90)
            turtle.pendown()
            turtle.write('日',font=('Arial',52,'normal'))
            turtle.penup()
            turtle.left(90)
            turtle.fd(30)
            turtle.right(90)
            turtle.fd(60)

turtle.setup(1000,600,500,500)
turtle.hideturtle()
turtle.penup()
turtle.bk(380)
date=time.strftime('%Y-%m+%d=',time.gmtime())
turtle.pendown()
drawDate(date)
turtle.exitonclick()

相关文章:


SSH 登录失败:Host key verification failed

PHP分页显示制作详细讲解

PHP自定义函数获取搜索引擎来源关键字的方法

在Zeus Web Server中安装PHP语言支持

再谈PHP中单双引号的区别详解

让你成为最历害的git提交人

将二进制数据转为16进制以便显示

php+ajax+json 详解及实例代码

PHP实现简单爬虫的方法

Python 2与Python 3版本和编码的对比

php实现数组中索引关联数据转换成json对象的方法

桌面中心(一)创建数据库

PHP设计模式之工厂模式与单例模式

php数组合并array_merge()函数使用注意事项

php封装的page分页类完整实例

wget使用技巧

getAttribute和getAttributeNode

获取IMSI

Yii2汉字转拼音类的实例代码

python中执行shell的两种方法总结