I never should have thrown that example at you without modification,
I just grabbed it from a project.
Here's a simpler example:
I just grabbed it from a project.
Here's a simpler example:
import json def make_json(): init_data = { 'rotor1_info': { 'name': 'rotor1', 'cipher': 'EKMFLGDQVZNTOWYHXUSPAIBRCJ', 'notches': ['R'], } } with open('simple.json', 'w') as f: json.dump(init_data, f) def test_read(): mydata = {} with open('simple.json') as f: mydata = json.load(f) for key, value in mydata.items(): print('key: {}, Value: {}'.format(key, value)) if __name__ == '__main__': make_json() test_read()running get these results:
Output:key: rotor1_info, Value: {'name': 'rotor1', 'cipher': 'EKMFLGDQVZNTOWYHXUSPAIBRCJ', 'notches': ['R']}