SoundCloud-Python AttributeError: 'ResourceList' object has no attribute 'collection'

SoundCloud-Python AttributeError: 'ResourceList' object has no attribute 'collection'

我遵循此处的指南 https://github.com/soundcloud/soundcloud-python (built around Python requests), and I am trying to list all the tracks in my soundcloud account (https://developers.soundcloud.com/docs/api/reference#tracks),以及它们相应的指标,例如播放次数、喜欢程度等

# create client object with app and user credentials
client = soundcloud.Client(client_id=client_id,
                           client_secret=client_secret,
                           username=username,
                           password=password)

# print authenticated user's username
name        =  client.get('/me').username
track_count =  client.get('/me').track_count
tracks      =  client.get('/tracks')
print name, track_count

我可以在 print 语句中获取值,但是如果我尝试这样做(取自示例)

for track in tracks.collection:
    print track.title

我收到这个错误:

AttributeError: 'ResourceList' object has no attribute 'collection'

知道如何解决这个问题吗?谢谢

尝试:

for track in tracks:
    print track.title

您也可以尝试如下定义曲目:

tracks      =  client.get('/tracks.json')