I read a file online and converted it to JSON. I've got the result working but wants to format the numbers (23456876
to a 23,456,875
and 345653
to 345,653
)
data_file = [{"name":"python", "downloads":23456876, "version": "3.4.2", "version_downloads": 345653 }]
I wrote the code to get the values but if i use a try
except
statement inside the for k in key
. It wouldn't convert and i also used another way but got cannot convert automatic fields to mamual formatting or something
titles = ["name", "downloads", "version", "Latest downloads"]
key = ["name", "downloads", "version", "version_downloads"]
i = 0
while i < len(data_file):
results = []
for k in key:
print("{}: {}".format(titles[key.index(k)], data_file[i][k]))
print()
i+=1
the result looks like this now:
name: python
downloads: 23456876
latest version: 3.4.2
Latest downloads: 345653
how can i print the downloads
to be:
downloads: 2,345,676
Latest downloads: 345653