当前位置:网站首页>The turtle library displays the system time
The turtle library displays the system time
2022-06-13 09:20:00 【Hello, teacher. I'm classmate Liu】
Today we have achieved turtle Display system time
The renderings are as follows :
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(" year ",font=('Arial',18,'normal'))
turtle.pencolor('green')
turtle.fd(40)
elif i == "=":
turtle.write(" month ",font=('Arial',18,'normal'))
turtle.pencolor('blue')
turtle.fd(40)
elif i == "+":
turtle.write(" Japan ",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()
边栏推荐
- JUC atomic accumulator
- C language: timer principle
- 攻防世界PWN play 条件竞争漏洞的利用
- QML compilation specification
- Three indexes reflecting system reliability in performance test: MTTF, MTTR and MTBF
- QML(06)——qml. Add a new folder under QRC
- 20211006 linear transformation
- Tutorial (5.0) 04 Fortint cloud services and scripts * fortiedr * Fortinet network security expert NSE 5
- JUC原子数组
- 图数据库Neo4j介绍
猜你喜欢

Tutorial (5.0) 01 Product introduction and installation * fortiedr * Fortinet network security expert NSE 5

C language: dynamic memory management

20211020 academician all drive system

Cisco, Huawei network equipment

Routing - static routing

turtle库显示系统时间

Neo4j - CQL use

QT multithreaded TCP server
![[implementation of depth first search]](/img/10/4f150e4fa0d4edf01483a72b881afe.jpg)
[implementation of depth first search]

CAS NO lock
随机推荐
C/s model and P2P model
20220606 关于矩阵的Young不等式
C language: sanziqi
Three indexes reflecting system reliability in performance test: MTTF, MTTR and MTBF
Batch read all voice files under the folder
Neo4j - CQL use
Neo4j环境搭建
Class loading overview
C language: Address Book
Resolve importerror:lib*** so--cannot open shared object file: No such... (pycharm/clion reports an error but the shell does not)
线上调试工具Arthas高级
20211018 some special matrices
Tutorial (5.0) 03 Security policy * fortiedr * Fortinet network security expert NSE 5
C language: timer principle
LeetCode 5259. Calculate the total tax payable
Necessary and sufficient conditions for diagonalization of 20211115 matrix; The full rank matrix does not necessarily have n linearly independent eigenvectors; Symmetric matrices must be diagonalized
C # introductory series (XIII) -- getting to know the structure for the first time
20211115 any n-order square matrix is similar to triangular matrix (upper triangle or lower triangle)
Library management system based on wechat applet Rar (thesis + source code)
Yolov5 face video stream