确定窗口大小的乌龟python设置

Mam*_*hid 5 python turtle-graphics python-3.x

在 Python 3+ 中,我试图运行turtle.setup(400, 500)但它不起作用。

没有名为 的引用setup

如何在 Python 3 中使用屏幕设置?

cdl*_*ane 5

根据您导入乌龟的方式,有(至少)三个选项。从最坏到最好:

选项1:

from turtle import *

setup(400, 500)
Run Code Online (Sandbox Code Playgroud)

选项 2:

import turtle

turtle.setup(400, 500)
Run Code Online (Sandbox Code Playgroud)

选项 3:

from turtle import Turtle, Screen

screen = Screen()
screen.setup(400, 500)
Run Code Online (Sandbox Code Playgroud)

如果这些对您不起作用,请使用有关运行 Python/turtle 的环境的更多信息更新您的问题。