用python画一个天安门华表
时间: 2023-05-20 22:04:33 浏览: 181
爱心源码-通过Python画一颗跳动的心
以下是用 Python 画天安门华表的代码:
```python
import turtle
# 设置画布大小
turtle.setup(800, 600)
# 设置画笔颜色和粗细
turtle.pensize(5)
turtle.pencolor("red")
# 画左边的华表
turtle.penup()
turtle.goto(-200, 0)
turtle.pendown()
turtle.forward(100)
turtle.left(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(200)
# 画右边的华表
turtle.penup()
turtle.goto(100, 0)
turtle.pendown()
turtle.forward(100)
turtle.left(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(200)
# 画上面的横梁
turtle.penup()
turtle.goto(-250, 200)
turtle.pendown()
turtle.forward(550)
# 画左边的斜梁
turtle.penup()
turtle.goto(-250, 200)
turtle.pendown()
turtle.right(45)
turtle.forward(100)
# 画右边的斜梁
turtle.penup()
turtle.goto(300, 200)
turtle.pendown()
turtle.left(90)
turtle.forward(100)
# 隐藏画笔
turtle.hideturtle()
# 等待用户关闭窗口
turtle.done()
```
希望能帮到你!
阅读全文