如何用python画六边形?
发布时间:2026-03-22 22:14:47

用Python编写六边形步骤:
1、首先加载turtle模块,这是Python自带的模块。
importturtle
2、准备一个turtle
t=turtle.Pen()
3、让t向前推进100个像素;
t.forward(100)
让t向左旋转60°;
t.left(60)
4、让步骤3重复六次:
foriinrange(6): t.fotward(100) t.left(60°)
你可以画一个完整的六边形。
