Python 函数未在turtle窗口中写入
我正在用python编写程序。要在turtle窗口中编写文本,我使用以下代码:Python 函数未在turtle窗口中写入,python,python-turtle,Python,Python Turtle,我正在用python编写程序。要在turtle窗口中编写文本,我使用以下代码: def write_text(center_x,center_y,text): # Write text on the Screen board.speed(1) print("I am here") board.penup() board.goto(center_x,center_y) board.write(text) 但这段代码并没有在turtle窗口中编写任何内容。有
def write_text(center_x,center_y,text): # Write text on the Screen
board.speed(1)
print("I am here")
board.penup()
board.goto(center_x,center_y)
board.write(text)
但这段代码并没有在turtle窗口中编写任何内容。有人能帮我吗?你的write\u text()
功能基本上很好。我会寻找其他你看不到文本的原因。你的钢笔颜色和背景颜色一样吗?您的屏幕DPI是否过于密集,无法看到turtle默认使用的小字体
尝试对函数进行简化,并使用一些代码来调用它:
from turtle import Screen, Turtle
FONT = ('Arial', 16, 'normal')
def write_text(center_x, center_y, text):
''' Write text on the Screen '''
board.penup()
board.goto(center_x, center_y)
board.write(text, font=FONT)
board = Turtle()
write_text(100, 100, "You are here.")
screen = Screen()
screen.exitonclick()
你的乌龟窗里还没有写东西吗