画画基础
import turtle # 导入 turtle 模块
# 初始化屏幕
screen = turtle.Screen()
pen = turtle.Turtle()
def draw_base():
pen.showturtle() # 显示箭头
pen.write("hello world") # 写字符串
pen.forward(300) # 前进 300 像素
pen.color("blue") # 画笔颜色改为 red
pen.left(90) # 箭头左转 90 度
pen.forward(300)
pen.goto(0, 50) # 去坐标(0,50)
pen.goto(0, 0)
pen.penup() # 抬笔。这样,路径就不会画出来
pen.goto(0, 300)
pen.pendown() # 下笔。这样,路径就会画出来
pen.circle(100) # 画圆
if __name__ == "__main__":
draw_base()
turtle.done() # 保持窗口打开
执行效果