首页 > 其他 > 详细

Working with Data Sources

时间:2016-11-15 08:21:22      阅读:193      评论:0      收藏:0      [点我收藏+]

1. The API is the link to request data from the host.

2. A endpoint is a route to retrive different data from the API.

3. Status codes indicate information about what happened with a request. Here are some codes that are relevant to GET requests:

  • 200 -- everything went okay, and the result has been returned (if any)
  • 301 -- the server is redirecting you to a different endpoint. This can happen when a company switches domain names, or an endpoint name is changed.
  • 401 -- the server thinks you‘re not authenticated. This happens when you don‘t send the right credentials to access an API (we‘ll talk about this in a later mission).
  • 400 -- the server thinks you made a bad request. This can happen when you don‘t send along the right data, among other things.
  • 403 -- the resource you‘re trying to access is forbidden -- you don‘t have the right permissions to see it.
  • 404 -- the resource you tried to access wasn‘t found on the server

4. json.dumps can convert the list and dictionary to string:

  best_food_chains_string = json.dumps(best_food_chains)

 Json.loads can convert the string to lists or dictionaries.

  fast_food_franchise_2 = json.loads(fast_food_franchise_string)

5. I can get the content of a response as a Python object by using .json() method.

  data = response.json()

6. .header property shows the content that how data was generated and how to decode it.

 

Working with Data Sources

原文:http://www.cnblogs.com/kingoscar/p/6064238.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!