为什么可以为我的对象提供代码完成代码完成?
VS代码为什么不弄清楚如何完成方法和属性? 当我写信时: ai_game。 什么都没有发生,没有出现的方法或属性列表
import pygame
class Ship:
"""A class to manage the ship."""
def __init__(self, ai_game):
"""Initialize the ship and set its starting position."""
self.screen = ai_game.screen
self.settings = ai_game.settings
self.screen_rect = ai_game.screen.get_rect()
Why doesn't VS Code figure out how to complete the methods and attributes?
When I write:
ai_game.
nothing happens, no list of methods or attributes appear
import pygame
class Ship:
"""A class to manage the ship."""
def __init__(self, ai_game):
"""Initialize the ship and set its starting position."""
self.screen = ai_game.screen
self.settings = ai_game.settings
self.screen_rect = ai_game.screen.get_rect()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为它不知道
ai_game
是什么。它可以是任何类型。例如,添加类型注释:在此示例中,我很确定您没有浮点,但是它将帮助代码知道哪种类型是
ai_game
实际上并为您提供帮助及其方法..Because it has no idea what
ai_game
is. It can be any type. Add a type annotation to it for example:Well in this example I'm pretty sure you don't have a float, but it'll help VS Code to know what type is
ai_game
actually and help you with its methods..