哪里出错了,帮我看看吧,谢谢
本帖最后由 皮卡丘大王 于 2023-1-1 23:03 编辑这个七段数码管绘制为什么没有颜色,也不显示年月日{:10_266:}
import turtle
import time
def drawGap():
turtle.penup()
turtle.fd(8)
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 else drawLine(False)
drawLine(True) if d in else drawLine(False)
drawLine(True) if d in else drawLine(False)
drawLine(True) if d in else drawLine(False)
turtle.left(90)
drawLine(True) if d in else drawLine(False)
drawLine(True) if d in else drawLine(False)
drawLine(True) if d in 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", 25, "normal"))
turtle.pencolor("green")
turtle.fd(40)
elif i == '月':
turtle.write('月', font=("Arial", 25, "normal"))
turtle.pencolor("yellow")
turtle.fd(40)
elif i == '日':
turtle.write('日', font=("Arial", 25, "normal"))
else:
drawDigit(eval(i))
def main():
turtle.setup(1000, 350, 200, 200)
turtle.penup()
turtle.fd(-300)
turtle.pensize(5)
date = "20221209"
drawDate(date)
turtle.hideturtle()
turtle.done()
main()
date = "20221209" 这个没有年‘、月、日三个字符串哦
import turtle
import time
def drawGap():
turtle.penup()
turtle.fd(8)
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 else drawLine(False)
drawLine(True) if d in else drawLine(False)
drawLine(True) if d in else drawLine(False)
drawLine(True) if d in else drawLine(False)
turtle.left(90)
drawLine(True) if d in else drawLine(False)
drawLine(True) if d in else drawLine(False)
drawLine(True) if d in 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", 25, "normal"))
turtle.pencolor("green")
turtle.fd(40)
elif i == '月':
turtle.write('月', font=("Arial", 25, "normal"))
turtle.pencolor("yellow")
turtle.fd(40)
elif i == '日':
turtle.write('日', font=("Arial", 25, "normal"))
else:
drawDigit(eval(i))
def main():
turtle.setup(1000, 350, 200, 200)
turtle.penup()
turtle.fd(-300)
turtle.pensize(5)
date = "2022年12月09日"
drawDate(date)
turtle.hideturtle()
turtle.done()
main()
51Arduino32 发表于 2023-1-1 23:22
date = "20221209" 这个没有年‘、月、日三个字符串哦
谢谢你{:10_254:}
页:
[1]