python学习入门,用七段数码管显示日期
在线制作工具
#用七段数码管显示日期
import turtle as t
def drawLine(draw): #绘制单个数码管
t.pendown() if draw else
t.penup()
t.fd(50)
t.rt(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)
t.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] else drawLine(False)
drawLine(True) if digit
in [0,1,2,3,4,7,8,9] else drawLine(False)
t.lt(180)
t.penup()
t.fd(20)
def drawDate(date): #通过eval()将数字转整数
for i in date:
drawDigit(eval(i))
def main():
t.setup(800,350,200,200)
t.penup()
t.fd(-300)
t.pensize(5)
drawDate('20230515')
t.hideturtle()
t.done()
main()
运行结果如下:

修改成数码管的样子如下(红字为修改内容):
#用七段数码管显示日期
import turtle as t
def drawLine(draw): #绘制单个数码管
t.penup()
t.fd(5)
t.pendown() if draw else
t.penup()
t.fd(50)
t.penup()
t.fd(5)
t.rt(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)
t.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] else drawLine(False)
drawLine(True) if digit
in [0,1,2,3,4,7,8,9] else drawLine(False)
t.lt(180)
t.penup()
t.fd(20)
def drawDate(date): #通过eval()将数字转整数
for i in date:
drawDigit(eval(i))
def main():
t.setup(800,350,200,200)
t.penup()
t.fd(-300)
t.pensize(5)
drawDate('20230515')
t.hideturtle()
t.done()
main()

修改成彩色数码管,显示的是当前日期,修改如下(红字为修改内容):
#用七段数码管显示日期
import turtle as t
import random
import datetime
t.colormode(255)
t.speed("fastest")
def drawLine(draw): #绘制单个数码管
t.penup()
t.fd(5)
t.pendown() if draw else
t.penup()
t.fd(50)
t.penup()
t.fd(5)
t.rt(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)
t.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] else drawLine(False)
drawLine(True) if digit
in [0,1,2,3,4,7,8,9] else drawLine(False)
t.lt(180)
t.penup()
t.fd(20)
def drawDate(date): #通过eval()将数字转整数
for i in date:
r=random.randint(0,255)
g=random.randint(0,255)
b=random.randint(0,255)
t.pencolor(r,g,b)
drawDigit(eval(i))
def main():
#t.setup(800,350,200,200)
t.penup()
t.fd(-300)
t.pensize(5)
current_day=datetime.date.today()
today_string = current_day.strftime('%Y%m%d')
drawDate(today_string)
t.hideturtle()
t.done()
main()

SAP分割评估的概念、应用场景及其系统实现介绍
概念介绍在了解SAP分割评估前,先了解下SAP的评估范围,我们知道在SAP中评估范围可以设置为公司层级或工厂层级。如果评估范围设置为公司层级,那么在公司下的同一物料都会使用相同的物料评估方法,比如,同一物料要么使用标准价,要么使用移动平均价。站长网2023-07-27 09:25:070008量子计算机一旦成熟,会给人类社会带来哪些改变
量子计算机的出现可能会对人类社会产生深迅速和广泛的影响。下面的文章将详细地探讨这个主题。1.密码学和信息安全传统的密码系统,如RSA和ECC,基于数学问题的困难性(如大数分解和离散对数问题)。然而,这些问题对于量子计算机来说并不困难。Shor的算法就是一个能在量子计算机上有效分解大数的算法。因此,一旦量子计算机成熟,现有的许多密码系统可能就无法保护信息安全了。0000电脑运行缓慢?原因分析及解决方法一览
近期有很多小伙伴反映电脑的运行速变得缓慢甚至卡顿,这确实会给工作和娱乐带来很大的困扰。要解决这个问题,我们首先需要了解导致电脑运行缓慢的原因。本文将为您详细介绍一些常见的原因,并提供一些有效的解决方法,帮助您恢复电脑的快速运行状态。电脑运行缓慢可能是由多种原因导致的,下面列举了一些常见的原因和解决方法:站长网2023-07-30 12:01:390000拼多多购物套路多?教你关闭免密支付功能,防止自动扣款
站长网2023-07-29 08:27:110000如何使用图案生成器的方法?
使用图案生成器的具体步骤可能因为不同的图案生成器而略有不同,但是大致流程如下:选择一个合适的图案生成器。可以在互联网上搜索相关的图案生成器,也可以使用自己的设计软件(如Photoshop、Illustrator等)中的图案生成器工具。打开图案生成器并选择一个基础图案或模板。有些图案生成器会提供默认的基础图案或模板,有些则需要使用者自己上传或选择。站长网2023-07-27 11:56:090000