我正在尝试定义一个类,该类返回带有歌曲标题,曲目编号和流派类型的字典(这是来自特定艺术家的歌曲的itunes API请求)。目前,当我在终端中运行我的文件时,没有返回任何内容(我没有收到语法错误或回溯)。我期待看到一个包含曲目名称,曲目编号和替代流派的字典。任何帮助都会很棒!
{"http://itunes.apple.com/searchcountry-US_entity-song_format-json_term-bon+iver": {"resultCount": 50, "results": [{"collectionExplicitness": "notExplicit", "releaseDate": "2011-06-21T07:00:00Z", "currency": "USD", "artistId": 273428126, "previewUrl": "http://audio.itunes.apple.com/apple-assets-us-std-000001/AudioPreview71/v4/29/b7/6d/29b76dbc-c7c2-a528-98c0-88250c90d61f/mzaf_8791054078902679680.plus.aac.p.m4a", "trackPrice": 1.29, "isStreamable": true, "trackViewUrl": "https://itunes.apple.com/us/album/holocene/id438685974?i=438685989&uo=4", "collectionName": "Bon Iver", "collectionId": 438685974, "trackId": 438685989, "collectionViewUrl": "https://itunes.apple.com/us/album/holocene/id438685974?i=438685989&uo=4", "trackCount": 10, "trackNumber": 3, "discNumber": 1, "collectionPrice": 9.99, "trackCensoredName": "Holocene", "trackName": "Holocene", "trackTimeMillis": 336613, "primaryGenreName": "Alternative", "artistViewUrl": "https://itunes.apple.com/us/artist/bon-iver/id273428126?uo=4", "kind": "song", "country": "USA", "wrapperType": "track", "artworkUrl100": "http://is3.mzstatic.com/image/thumb/Music/v4/f6/41/9b/f6419bd5-7fa7-6046-04d0-fcae6ecf9d96/source/100x100bb.jpg", "collectionCensoredName": "Bon Iver", "artistName": "Bon Iver", "artworkUrl60": "http://is3.mzstatic.com/image/thumb/Music/v4/f6/41/9b/f6419bd5-7fa7-6046-04d0-fcae6ecf9d96/source/60x60bb.jpg", "trackExplicitness": "notExplicit", "artworkUrl30": "http://is3.mzstatic.com/image/thumb/Music/v4/f6/41/9b/f6419bd5-7fa7-6046-04d0-fcae6ecf9d96/source/30x30bb.jpg", "discCount": 1}, {"contentAdvisoryRating": "Explicit", "collectionExplicitness": "explicit", "releaseDate": "2010-11-22T08:00:00Z", "currency": "USD", "artistId": 2715720, "previewUrl": "http://a1044.phobos.apple.com/us/r30/Music/ac/5a/7b/mzm.wurlfubj.aac.p.m4a", "trackPrice": 1.29, "isStreamable": true, "trackViewUrl": "https://itunes.apple.com/us/album/monster-feat-jay-z-rick-ross-nicki-minaj-bon-iver/id403822142?i=403822318&uo=4", "collectionName": "My Beautiful Dark Twisted Fantasy", "collectionId": 403822142, "trackId": 403822318, "collectionViewUrl":
缓存JSON:
without(X,[X,_],[]).
without(X,[K|Xs],[K|AlmoustLast]) :-
without(X,Xs,AlmoustLast).
答案 0 :(得分:0)
两件事:
首先,你有一些你不需要/想要的等号(意思,作业)。这样:
self.trackName =song_dict["trackName"]
self.trackNumber=song_dict=["trackNumber"]
self.primaryGenreName =song_dict=["primaryGenreName"]
应该成为这个:
self.trackName = song_dict["trackName"]
self.trackNumber = song_dict["trackNumber"]
self.primaryGenreName = song_dict["primaryGenreName"]
接下来,您不会在Python中从类构造函数(__init__
)返回内容。所以删除return语句。