python - Create List from List of Key-Values -
given json structure below, want grab data item, pull 1 of values link
out randomly.
using random
- familiar grabbing random value list. i'm stuck how make list list. see code below json.
item0: 0 caption: "caption 0" link: "www.item0.com" type: "type0" 1 caption: "caption 1" link: "www.item1.com" type: "type1"
python:
chosen_item = "item0" firebase = firebase.firebaseapplication('https://app.firebaseio.com') result = firebase.get(chosen_item, none) if result: in result: result_link = (i['link']) print result_link
the if-statement
loops through , returns link
's in item unicode
type. how make list this? ( result_link
)
chosen_item = "item0" firebase = firebase.firebaseapplication('https://app.firebaseio.com') result = firebase.get(chosen_item, none) if result: links = [] in result: links.append(i['link'])
Comments
Post a Comment