Skip to content

Instantly share code, notes, and snippets.

@blogcacanid
Last active April 18, 2020 06:21
Show Gist options
  • Save blogcacanid/2a7363219f29638bba0a6a2a5c0ad22d to your computer and use it in GitHub Desktop.
Save blogcacanid/2a7363219f29638bba0a6a2a5c0ad22d to your computer and use it in GitHub Desktop.
covid19.py Sistem Informasi Covid-19 Python Detail Dunia
def detail_dunia():
print('*** DETAIL COVID-19 DUNIA')
url = "https://api.kawalcorona.com/"
data = requests.get(url).text
obj = json.loads(data)
pTable = PrettyTable()
pTable.field_names = ['No.', 'Country/Region', 'Confirmed', 'Recovered', 'Deaths', 'Active']
# Mengatur posisi text r=right, l=left, c=center
pTable.align['No'] = 'r'
pTable.align['Country/Region'] = 'l'
pTable.align['Confirmed'] = 'r'
pTable.align['Recovered'] = 'r'
pTable.align['Deaths'] = 'r'
pTable.align['Active'] = 'r'
no = 0
for i in obj:
no += 1
row_details = [no, i['attributes']['Country_Region'], i['attributes']['Confirmed'], i['attributes']['Recovered'], i['attributes']['Deaths'], i['attributes']['Active']]
pTable.add_row(row_details)
print(pTable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment