当前位置:网站首页>turtle库显示系统时间
turtle库显示系统时间
2022-06-13 09:04:00 【老师好,我是刘同学】
今天我们实现了turtle显示系统时间
效果图如下:
import turtle,time
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(digit):
drawLine(True) if digit in [2, 3, 4, 5, 6, 8, 9] else drawLine(False)
drawLine(True) if digit in [0, 1, 3, 4, 5, 6, 7, 8, 9] else drawLine(False)
drawLine(True) if digit in [0, 2, 3, 5, 6, 8, 9] else drawLine(False)
drawLine(True) if digit in [0, 2, 6, 8] else drawLine(False)
turtle.left(90)
drawLine(True) if digit in [0, 4, 5, 6, 8, 9] else drawLine(False)
drawLine(True) if digit in [0, 2, 3, 5, 6, 7, 8, 9] else drawLine(False)
drawLine(True) if digit in [0, 1, 2, 3, 4, 7, 8, 9] else drawLine(False)
turtle.left(180)
turtle.penup()
turtle.fd(20)
def drawDate(date):
turtle.pencolor("red")
for i in date:
if i == "-":
turtle.write("年",font=('Arial',18,'normal'))
turtle.pencolor('green')
turtle.fd(40)
elif i == "=":
turtle.write("月",font=('Arial',18,'normal'))
turtle.pencolor('blue')
turtle.fd(40)
elif i == "+":
turtle.write("日",font=('Arial',18,'normal'))
else:
drawDigit(eval(i))
def main():
turtle.setup(800,350,200,200)
turtle.penup()
turtle.fd(-300)
turtle.pensize(5)
drawDate(time.strftime("%Y-%m=%d+",time.gmtime()))
turtle.hideturtle()
turtle.done()
main()
边栏推荐
- Neo4j - CQL使用
- 20211108 A转置乘A是正定矩阵吗?A转置乘A是正定矩阵的充分必要条件是什么?
- [security] how to counter attack from 0 to 1 to become a security engineer with zero Foundation
- Sonar scan ignores the specified file
- 图数据库Neo4j介绍
- Talking about acid of database
- Use typescript to complete simple snake eating function
- C language: data storage in memory
- CAS NO lock
- Online debugging tool Arthas Foundation
猜你喜欢

Cisco, Huawei network equipment
![[network security penetration] if you don't understand CSRF? This article gives you a thorough grasp](/img/16/907c7c414502b22129f774fbffdafe.png)
[network security penetration] if you don't understand CSRF? This article gives you a thorough grasp

Redirect vulnerability analysis of network security vulnerability analysis

Routing - static routing

The Jenkins console does not output custom shell execution logs

Library management system based on wechat applet Rar (thesis + source code)

20211104 为什么相似矩阵的迹相同

基于微信小程序的图书馆管理系统.rar(论文+源码)

How Simulink adds modules to the library browser

Installation of sonarqube code quality management platform (to be continued)
随机推荐
Some websites of QT (software download, help documents, etc.)
Class loading overview
Two good kids
C/S模型与P2P模型
20211108 A转置乘A是正定矩阵吗?A转置乘A是正定矩阵的充分必要条件是什么?
Tutorial (5.0) 02 Management * fortiedr * Fortinet network security expert NSE 5
Neo4j - CQL使用
Collection of various books
202012 CCF test questions
Completely uninstall PostgreSQL under Linux
Neo4j - CQL use
Neo4j環境搭建
Top+jstack to analyze the causes of excessive CPU
pytorch统计模型的参数个数
Talking about acid of database
20211028 Stabilizability
Void* pointer
20211020 academician all drive system
C/s model and P2P model
C language: data storage in memory