美文网首页
Get data from API and be careful

Get data from API and be careful

作者: 彩虹金刚_Q | 来源:发表于2018-08-31 12:12 被阅读0次

    Today I need to get data from existing API and show it on my website

    yesterday I searched the answer is Django Rest, but after several trials I found it more like a create API tool, And then I found another tool which saved my day

    pip install requests

    Python is a really simple and easy tool with a lot of useful models

    after getting my data, you need to handle them to do what you need and here is a useful one I need to remenber

    import requests

    import json

    r= requests.get('http://10.75.10.254/getdeviceinfo.php')

    line= r.text

    obj = json.loads(line)

    i = 0

    while i < len(obj):

    print(obj[i]['nickname'])

    i=i+1

    cut json into string and use it

    and circulation items in Python is much different from other languages need to be really careful

    相关文章

      网友评论

          本文标题:Get data from API and be careful

          本文链接:https://www.haomeiwen.com/subject/klsswftx.html