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 Oh, what the options are indent, and ensure_ascii?
April 4th 20 at 13:12

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

In [3]: hosts = yaml.safe_load(ymlsample) 
In [4]: hosts 
{'branch1': {'name': 'branch1',
 'ip': '',
 'ASN': 65101,
 'type': 'cisco',
 'auth': {'username': 'username', 'password': 'password'}},
 'branch2': {'name': 'branch2',
 'ip': '',
 '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