在这段代码上增加代码,在右下角显示学号“220604404107”和姓名“蒋颖” import turtle ,datetime 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) drawL ine (True) if d in [0,,1.3.4.5.6.7,8,9] elze draWL ine (False) dravLine (rrue) if din [0,2.3,5,6,8,9〕 elze drvL ine (Falze) drawLine (True) if d in turtle. left (90) [0, 2, 6, 8] else drawline (False) drawLine (True) if a 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) turtle. left (180) [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) 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(-350) turtle. pensize (5) drawDate (datetime.datetime.now().strftime (‘%Y-%m=%d+’)) turtle.hide turtle() main ()
时间: 2024-02-14 13:13:38 浏览: 80
白色大气风格的旅游酒店企业网站模板.zip
你可以在这段代码的末尾添加以下代码来显示学号和姓名:
```python
# 获取学号和姓名
student_id = "220604404107"
name = "蒋颖"
# 创建标签
label = turtle.Turtle()
label.penup()
label.goto(350, -250)
label.write(f"Student ID: {student_id}\nName: {name}", align="right", font=("Arial", 12, "normal"))
```
这个程序会在绘制完日期后,在窗口的右下角添加一个文本标签来显示学号和姓名。你只需要将`student_id`和`name`变量替换成你自己的学号和姓名即可。
阅读全文