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。
我该如何解决这个问题?