【发布时间】:2021-12-17 02:19:31
【问题描述】:
您好,这是我第一次尝试用 python 编写视频游戏。 所以我找到了一个教程视频,它与我的(mac)在同一操作系统上运行,但是当我在视频中编写设置时:
#Setup
import turtle
wn=turtle.Screen
wn.title("Pong")
wn.bgcolor("black")
wn.setup(width=800, heigth=600)
wn.tracer(0)
#Main game loop
while True:
wn.update()
出现了这个错误:
AttributeError: 'function' object has no attribute 'title'
有人知道这意味着什么以及如何解决吗? 顺便说一句,我正在运行 python 3.10.0
【问题讨论】:
-
turtle.Screen是一个函数。turtle.Screen()调用该函数并返回一个窗口对象,该对象具有您尝试调用的方法。
标签: python visual-studio-code attributeerror python-turtle python-3.10