Wie deaktiviere ich die Ersetzung von Kyrillisch durch \uXXXX in Strings bei der Konvertierung zu JSON
📁 Python, Hilfe, Beispiel
Beim Versuch, JSON mit dump formatiert auszugeben, werden russische Zeichen nicht mehr angezeigt. Es erscheint so etwas wie ""beliebiges Feld, z.B. Address"": ""\\u0443\\u043b\\u0438\\u0446\\u0430 \\u041c\\u0430 usw.""
Ich habe json.dumps().encode(""utf8"") und codac convert ausprobiert - nichts hilft.
def load_data(filepath):n with open(filepath, 'r', encoding='utf-8') as fh: n data = json.load(fh) # laden der Daten aus der Datei in das Dictionary datan return data Verwenden Sie den Parameter :
Aus :
If
ensure_asciiis true (the default), the output is guaranteed to have all incoming non-ASCII characters escaped. Ifensure_asciiis false, these characters will be output as-is.
Beispiel:
In [41]: with open(fn, 'r', encoding='utf-8') as f: ...: data = json.load(f) ...: ...: print(json.dumps(data, ...: sort_keys=False, ...: indent=4, ...: separators=(',' Anmelden um eine Antwort zu hinterlassen