From 12044e95c2f6a189a3d51764a9474b8d2a27f682 Mon Sep 17 00:00:00 2001 From: Joshua Ellis <67237931+SpicyTakis@users.noreply.github.com> Date: Fri, 2 Oct 2020 22:42:36 -0400 Subject: [PATCH] Added json example --- Code/Json assigning and reading.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Code/Json assigning and reading.py diff --git a/Code/Json assigning and reading.py b/Code/Json assigning and reading.py new file mode 100644 index 0000000..6ce1a14 --- /dev/null +++ b/Code/Json assigning and reading.py @@ -0,0 +1,17 @@ +#first import the json module +import json + +#next we will now ask the user for input and assign a variable +invar = input('What to ask') + +#now we will make a empty json, which is a sort of organized file +data = {} + +#we will now assign the "name" section to what the user types +data['name'] = invar + +#next we will print the finalized json with json.dumps which cleans it up +print(json.dumps(data, indent=4)) + +#finally we can read from the json +print(data['name'])