Otenka Data with Python
Received data from the server, you will obligatory use the celle for the topic does not, there is a few more able to reap and to enlighten the data more reliable.
Here's the primer that, how to analyze and return the concrete data from the JSON OPTER with the help of Python:
Acceptance Answer Json
JSON
[
{
"ID": 1,
"Name": "John Dow",
"Age": 30,
"City": "New York"
}
{
"ID": 2,
"Name": "Jane Smith",
"Age": 25,
"City": "Los -egeles"
}
]
Using Python for Analysis and Vozurati Data
`Python
JSON IMport
#This that the answering json is hoped in the expiry, called "data"
Data = [
{"ID": 1, "Name": "John Dou", "Azrast": 30, "City": "New York"},
{"ID": 2, "Name": "Jayin Smith", "Azrast": 25, "City": "Los -Andjels"}
]
Recording the function for extinguishing concrete data
Def Get_data (Data):
Keys_to_extract = ["ID", "Name", "Age"]
For the item B:
Extraird_info = {}
For key in Keys_to_extract:
If the key in the element:
Extraird_info [Key] = Item [Key]
Favored _info Exit
#Prier using
For a man in get_data (Data):
Pack (man)
In this primer, we delay the function of Get_data
, which takes off lists (Data
) and the expression of the generator, which is the maintenance of the General ( ). We use the section “Promer Using”, to prodigonstrate, how to identify the data of the data.
Access to the Conquret Don
To make access to the conquret data, you can just use the expression of the generator:
`Python
For a man in get_data (Data):
Pack (man ["ID"])
Pack (person ["name"])
In the quality of the alternatives, if you want to use the Cycling “for” the generator, you can define the uniform function, which dissolves this argument:
`Python
Def Get_Person (man):
Return {"ID": Person ["ID"], "Name": Person ["Name"]}
#Prier using
Data = [
{"ID": 1, "Name": "John Dou", "Azrast": 30, "City": "New York"},
{"ID": 2, "Name": "Jayin Smith", "Azrast": 25, "City": "Los -Andjels"}
]
For the man in the data:
PRINT (GET_Person (Man))
This underweight is all overwhelmed by the work with the more large data sets, which are not written in memory.
Leave a Reply