Reputation: 333
Trying to read a json file and return as dictionary:
def js_r(filename):
with open('num.json', 'r')as f_in:
json_d = f_read()
How to return the dict function?
Upvotes: 33
Views: 37762
Reputation: 77347
Use the json
module to decode it.
import json
def js_r(filename: str):
with open(filename) as f_in:
return json.load(f_in)
if __name__ == "__main__":
my_data = js_r('num.json')
print(my_data)
Upvotes: 49