python画出一个太极图
时间: 2023-10-16 07:19:43 浏览: 135
好的,以下是绘制一个简单的太极图的 Python 代码:
```python
import turtle
# 创建画布
screen = turtle.Screen()
screen.setup(400, 400)
screen.bgcolor('white')
# 创建画笔
pen = turtle.Turtle()
pen.hideturtle()
pen.speed(0)
pen.pensize(3)
# 绘制白色半圆
pen.penup()
pen.goto(0, 100)
pen.pendown()
pen.fillcolor('white')
pen.begin_fill()
pen.circle(100, 180)
pen.end_fill()
# 绘制黑色半圆
pen.penup()
pen.goto(0, -100)
pen.pendown()
pen.fillcolor('black')
pen.begin_fill()
pen.circle(100, 180)
pen.end_fill()
# 绘制两个小圆
pen.penup()
pen.goto(0, 35)
pen.pendown()
pen.fillcolor('black')
pen.begin_fill()
pen.circle(20)
pen.end_fill()
pen.penup()
pen.goto(0, -35)
pen.pendown()
pen.fillcolor('white')
pen.begin_fill()
pen.circle(20)
pen.end_fill()
turtle.done()
```
运行代码后,即可在画布上看到一个简单的太极图。
阅读全文