概述
port datetime
import turtle
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(d):
drawLine(True) if d in [2, 3, 4, 5, 6, 8, 9] else drawLine(False)
drawLine(True) if d in [0, 1, 3, 4, 5, 6, 7, 8, 9] else drawLine(False)
drawLine(True) if d in [0, 2, 3, 5, 6, 8, 9] else drawLine(False)
drawLine(True) if d in [0, 2, 6, 8] else drawLine(False)
turtle.left(90)
drawLine(True) if d in [0, 4, 5, 6, 8, 9] else drawLine(False)
drawLine(True) if d in [0, 2, 3, 5, 6, 7, 8, 9] else drawLine(False)
drawLine(True) if d 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("yellow")
for z in date:
if z == '-':
turtle.write("年")
turtle.pencolor("green")
turtle.fd(40)
elif z == '=':
turtle.write("月")
turtle.pencolor("blue")
turtle.fd(40)
elif z == "+":
turtle.write("日")
turtle.pencolor("yellow")
turtle.fd(40)
else:
drawDigit(eval(z))
def main():
turtle.setup(800, 350, 200, 200)
turtle.penup()
turtle.fd(-350)
turtle.pensize(5)
drawDate(datetime.datetime.now().strftime("%Y-%m=%d+"))
turtle.hideturtle()
main()
import time
import turtle
def koch(size, n):
if n == 0:
turtle.fd(size)
else:
for angle in [0, 60, -120, 60]:
time.sleep(0.2)
turtle.left(angle)
koch(size / 3, n - 1)
def main():
turtle.setup(800, 400)
# time.sleep(1)
turtle.speed(-1)
turtle.penup()
turtle.goto(-300, -50)
turtle.pendown()
turtle.pensize(3)
turtle.pencolor("blue")
koch(600, 3)
turtle.hideturtle()
main()
最后
以上就是自觉金针菇为你收集整理的手把手python实现七段数码管绘制,低阶教程的全部内容,希望文章能够帮你解决手把手python实现七段数码管绘制,低阶教程所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复