[Python] Save Unicode characters (e.g. æ ø å) to JSON file [duplicate]

Discussão em 'Python' iniciado por Stack, Agosto 15, 2025.

  1. Stack

    Stack Membro Participativo

    I try to save a dictionary. The dictionary looks good, but the output file replaces the Norwegian ø symbol with \u00f8.

    test.py:

    import json

    my_dict=[{
    'organisasjonsnummer': '123456789',
    'vedtektsfestetFormaal': ['Automasjonstjenester, service og leverandør av teknisk utstyr.']
    }]


    with open("out.json", "w") as f:
    f.write(
    json.dumps(my_dict, indent=4)
    )


    out.json:

    [
    {
    "organisasjonsnummer": "123456789",
    "vedtektsfestetFormaal": [
    "Automasjonstjenester, service og leverand\u00f8r av teknisk utstyr."
    ]
    }
    ]


    How to fix this?

    Continue reading...

Compartilhe esta Página