首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >self在这种情况下会是什么?-文档中没有说self应该是什么

self在这种情况下会是什么?-文档中没有说self应该是什么
EN

Stack Overflow用户
提问于 2020-08-16 06:47:28
回答 2查看 60关注 0票数 0
代码语言:javascript
复制
import cfbd  # API for accessing all sorts of college football data.

team_player_stats = cfbd.PlayersApi.get_player_season_stats(self=[], year=2019, team="Georgia", category="passing")
print(team_player_stats)

它说self没有定义,但我不确定self是什么。

EN

回答 2

Stack Overflow用户

发布于 2020-08-16 06:58:48

您熟悉如何使用Python类和方法吗?

如果您按照文档here操作,它将向您展示如何实例化PlayersApi和使用get_player_season_stats方法

代码语言:javascript
复制
# create an instance of the API class
api_instance = cfbd.PlayersApi()
year = 56 # int | Year filter
team = 'team_example' # str | Team filter (optional)
conference = 'conference_example' # str | Conference abbreviation filter (optional)
start_week = 56 # int | Start week filter (optional)
end_week = 56 # int | Start week filter (optional)
season_type = 'season_type_example' # str | Season type filter (regular, postseason, or both) (optional)
category = 'category_example' # str | Stat category filter (e.g. passing) (optional)

try:
    # Player stats by season
    api_response = api_instance.get_player_season_stats(year, team=team, conference=conference, start_week=start_week, end_week=end_week, season_type=season_type, category=category)
    print(api_response)
except ApiException as e:
    print("Exception when calling PlayersApi->get_player_season_stats: %s\n" % e)
票数 0
EN

Stack Overflow用户

发布于 2020-08-16 06:59:25

Self用于类方法声明,作为一种初始值。在这种情况下,您试图在对象本身上声明一个空列表。

尝试删除声明。自我并不是用来拥有某种价值的。

干杯

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63431472

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档