I have the below code which expects 1 or more file names as arguments.
It works for one file but now the input arguments can be multiple files such as 1.json 2.json 3.json.
How can I handle this?
import sys
import os
import json
inFile = sys.argv[1]
print(inFile)
with open(inFile, 'r') as file:
try:
json_data = json.load(file)
except ValueError as e:
print "Invalid Json supplied:%s" % e
exit(1)
else:
print "json file ok"
print(json_data)