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
网友评论