Strava API文档提供了以下示例代码,我复制并输入了自己的访问令牌和俱乐部ID:
from __future__ import print_statement
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint
# Configure OAuth2 access token for authorization: strava_oauth
swagger_client.configuration.access_token = 'MY_ACCESS_TOKEN'
# create an instance of the API class
api_instance = swagger_client.ClubsApi()
id = MY_CLUB_ID # Integer | The identifier of the club.
page = 56 # Integer | Page number. (optional)
perPage = 56 # Integer | Number of items per page. Defaults to 30. (optional) (default to 30)
try:
# List Club Activities
api_response = api_instance.getClubActivitiesById(id, page=page, perPage=perPage)
pprint(api_response)
except ApiException as e:
print("Exception when calling ClubsApi->getClubActivitiesById: %s\n" % e)
我尝试运行它,但是出现了错误:
from __future__ import print_statement
SyntaxError: future feature print_statement is not defined
我也发现在导入swagger_client
时会遇到同样的问题。我尝试为每个软件包安装程序,但没有任何改变。我看到对于__future__
,我应该使用> Python 2.7,但我目前使用的是3.6。
我该如何解决这个问题?
from __future__ ...
。请参阅如何使用from __future__ import print_function。 - Helenimport swagger_client ModuleNotFoundError: 找不到名为'swagger_client'的模块
- runnerpaul