How to write to a file so you can edit manually?

Tell me the library in which to write the file data so that they can be easily edited
(in the file).
Before that it used json encode Russian alphabet, and look for the appropriate variables was difficult.

Maybe if you write the dictionary file so that each object was on the next line ?
For easier visual search.
Or suggest the library is well suited for such purposes .

Sorry for the small vocabulary, described as best I could.
April 4th 20 at 13:08
3 answers
April 4th 20 at 13:10
Solution
https://docs.python.org/3.8/library/json.html#json.dump Oh, what the options are indent, and ensure_ascii?
April 4th 20 at 13:12
Solution
yaml

In [1]: import yaml 
In [2]: ymlsample=""" 
 ...: branch1: 
 ...: name: branch1 
 ...: ip: 1.2.3.4 
 ...: ASN: 65101 
 ...: type: cisco 
 ...: auth: 
 ...: username: username 
 ...: password: password 
 ...: branch2: 
 ...: name: branch2 
 ...: ip: 2.3.4.5 
 ...: ASN: 65102 
 ...: type: juniper 
 ...: auth: 
 ...: username: username 
 ...: password: password 
 ...: """ 

In [3]: hosts = yaml.safe_load(ymlsample) 
In [4]: hosts 
Out[4]: 
{'branch1': {'name': 'branch1',
 'ip': '1.2.3.4',
 'ASN': 65101,
 'type': 'cisco',
 'auth': {'username': 'username', 'password': 'password'}},
 'branch2': {'name': 'branch2',
 'ip': '2.3.4.5',
 'ASN': 65102,
 'type': 'juniper',
 'auth': {'username': 'username', 'password': 'password'}}}
April 4th 20 at 13:14
json.dumps(my_data, ensure_ascii=False)
There above answered correctly with reference to documentation.
The ensure_ascii argument requires to be escaped non-ASCII characters during serialization. If it is put to False, it will be what you need.

Find more questions by tags Python