用python画出太极图
时间: 2023-04-09 10:03:21 浏览: 494
可以使用Python中的turtle库来画出太极图。以下是示例代码:
```python
import turtle
# 设置画布大小和背景色
turtle.setup(500, 500)
turtle.bgcolor("white")
# 定义画笔颜色和大小
turtle.pensize(3)
turtle.pencolor("black")
# 画出黑色半圆
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(100, 180)
turtle.end_fill()
# 画出白色半圆
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(100, -180)
turtle.end_fill()
# 画出两个小圆
turtle.penup()
turtle.goto(-30, 60)
turtle.pendown()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(30, -60)
turtle.pendown()
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 显示画布
turtle.done()
```
运行代码后,即可看到画出的太极图。
阅读全文
相关推荐


















