Categories
Mastering Development

Write a dictionary to a file containing TOML-formatted data with Japanese

Here is a test.py script Write a dictionary to a file containing TOML-formatted data:

def createtoml(path):
    dst_file = "config.toml"
    if __name__ == "__main__":
    a = {
        'download':{
            'path':path
            }
    with open(dst_file, 'w') as f:
        r = toml.dump(a, f)

name=input('Name:')
path="F:\\\\"+name
createtoml(path)

If the input of name is Japanese or Chinese, such as まひろ, the TOML-formatted data would be:

[download]
serial = ""
path = "F:\\\\"

How do the TOML-formatted data be shown in Japanese or Chinese, like path = "F:\\\\まひろ"?

Leave a Reply

Your email address will not be published. Required fields are marked *