用python画一个广州塔
时间: 2023-10-24 19:08:59 浏览: 133
抱歉,作为AI语言模型,我无法直接绘制图形。不过,以下是一个可以用Python和turtle库绘制广州塔的示例代码:
```python
import turtle
# 设置初始位置和角度
turtle.penup()
turtle.goto(-200, 0)
turtle.pendown()
turtle.setheading(0)
# 绘制塔身
turtle.color('gray')
turtle.begin_fill()
turtle.forward(400)
turtle.right(90)
turtle.forward(400)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(300)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(400)
turtle.right(90)
turtle.forward(400)
turtle.end_fill()
# 绘制塔顶
turtle.penup()
turtle.goto(-100, 400)
turtle.pendown()
turtle.color('white')
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 绘制塔尖
turtle.penup()
turtle.goto(-100, 500)
turtle.pendown()
turtle.color('yellow')
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
# 绘制塔上的小球
turtle.penup()
turtle.goto(-180, 420)
turtle.pendown()
turtle.color('red')
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(80, 420)
turtle.pendown()
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
turtle.done()
```
运行上述代码,即可在窗口中看到绘制出的广州塔。可以根据自己的需要调整塔身和塔顶的颜色、大小等参数。