Quantcast
Channel: Programming – Xinyustudio
Viewing all articles
Browse latest Browse all 284

10 lines of code: using json in python

$
0
0

1.  import httplib,json
2.  url =
‘www.yupoo.com’
3.  path =
‘/api/json/api_key=d74aad0331494be468c07f47987b099b&method=yupoo.photos.licenses.getInfo’
4.  conn = httplib.HTTPConnection(url)
5.  conn.request(“GET”, path)
6.  response = conn.getresponse()
7.  if response.status == 200 :
8.      result = response.read()
9.      result2 = json.loads(result)
10.     print result2['stat']

If the above code is saved as Demo.py, in Cmd window, run this: “python Demo.py

image

Download Demo.py.


Filed under: Programming

Viewing all articles
Browse latest Browse all 284

Trending Articles