below is my python code
r = requests.get("https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=50&channelId="+CHANNELID+"&order=date&key="+DEVELOPER_KEY)
json = r.json()
items = json.get("items")
videos = []
for x in items:
title = x["snippet"]["title"]
videoId = x["id"]["videoId"]
channelTitle = x["snippet"]["channelTitle"]
cam_thumbnails = x["snippet"]["thumbnails"]["medium"]["url"]
publishedAt = x["snippet"]["publishedAt"]
data = { "title" : title,
"videoId" : videoId,
"channelTitle" : channelTitle,
"cam_thumbnails" : cam_thumbnails,
"publishedAt" : publishedAt,
}
videos.append(data)
print json.dumps(videos) # this code cause problem
I inserted 'dict' to 'list' and then called json.dumps() But, error was arised error messege is 'dict' object has no attribute 'dumps'
What is problem?, and How can I solve this problem?
jsonwith result r.json(), json has become a dictionary. changejsonto other name and ensure you import json module, should work