Question: PYTHON 2.7 Notes: Dictionary has two ways to initialize data dict() datal'school']-,SChoo!name, datal'address] = ,1000 School Avenue, Location, State 11111, data['phone'] ='(123) 789-0123, data =
PYTHON 2.7
![PYTHON 2.7 Notes: Dictionary has two ways to initialize data dict() datal'school']-,SChoo!name,](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66efa49892daa_27266efa49887662.jpg)
Notes: Dictionary has two ways to initialize data dict() datal'school']-,SChoo!name, datal'address] = ,1000 School Avenue, Location, State 11111, data['phone'] ='(123) 789-0123, data = { 'school': 'Schoolname', address: , 1000 School Avenue, Location, State 11 111', 'phone','( 123) 789-01231 Print the results as follows by accessing the defined dictionary school: SChoolname phone: (123) 789-0123 Use json to store above dictionary in and then print item, key and values You need to be familiar with the following two json functions: json.dumps(object), which dumps an ob- ject to a json format (string), json.loads(a json format string), which loads a json format string back to the original object. We do not care about if the original object is list, dictionary or others. json.dumps() can automatically recognize Note, json.load (object) only can only load an object, not a file Task: Data Serialization Store a number of different types objects (e.g., list, dictionary, array) to a file and then load the objects from the file Write a function to dump list object items = 1,2,34,5 and above dictionary to a file called task6data, and then load them from the same file and print
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
