Skip to main content
 首页 » 编程设计

python之如何阻止 turtle 即使拿起笔也不会画画

2025年05月04日10shangdawei

我在 python 中使用 turtle 模块。问题是每当我让 turtle 移动时,即使笔在上面我也会画画。例如,如果我运行这个程序:

import turtle 
 
turtle.penup 
turtle.goto(0,50) 

turtle 移动到(0,50)时仍会画一条线 为什么会这样?如何预防?

请您参考如下方法:

看起来你实际上并没有调用 turtle.penup。试试这个:

import turtle 
 
turtle.penup() 
turtle.goto(0,50)