There are 2 files one.cfg , two.cfg .
How to encode these 2 files into one files.json ?
There are 2 files one.cfg , two.cfg .
How to encode these 2 files into one files.json ?
First, we load the contents of our 2 files, and then we load them into the json structure, then we open a new file where we will save it and save it with the dump command, everything is simple :)
import json a = open('one.cfg', 'r') b = open('two.cfg', 'r') data = { 'one.cfg' : a.read(), 'two.cfg' : b.read(), } with open('data.json', 'w') as f: json.dump(data, f) Source: https://ru.stackoverflow.com/questions/702493/
All Articles