码迷,mamicode.com
首页 > 其他好文 > 详细

Working with Data Sources

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

标签:property   method   generated   his   company   als   foo   server   for   

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

标签:property   method   generated   his   company   als   foo   server   for   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!