Skip to content

Commit a1b1366

Browse files
Create Python_rest_data_process.py
1 parent 653863d commit a1b1366

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Python_rest_data_process.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import json
2+
import requests
3+
person_ISS=[]
4+
person_Tiangong=[]
5+
def space_data(url):
6+
data = requests.get(url)
7+
# print(data.json())
8+
dump = data.json()
9+
for person in dump["people"]:
10+
print(person["craft"])
11+
if (person["craft"] == "ISS"):
12+
person_ISS.append(person["name"])
13+
else:
14+
person_Tiangong.append(person["name"])
15+
16+
17+
print("Total number of persons in ISS" +" "+ str(len(person_ISS)))
18+
print("Total number of persons in ISS" +" "+ str(len(person_Tiangong)))
19+
20+
space_data("http://api.open-notify.org/astros.json")

0 commit comments

Comments
 (0)