masklinn í dag viðrar vel til loftárása | xilebo a écrit :
bon, si je mets Code :
- j = json.dumps(t , ensure_ascii = False)
| ca fonctionne. Sauf que dans mon exemple ca fonctionne, je peux print(j) , mais dans mon code ,j'ai une erreur Error'charmap' codec can't encode character '\u2026' in position 756: character maps to <undefined>
| Je suppose que cela veut dire qu'il y a un caractère non utf8 dedans ? Mais comment savoir lequel
|
Non, ça veut dire que dans ton bricolage le codec "charmap" est sélectionné et ne sait pas encoder U+2026 (HORIZONTAL ELLIPSIS). 1. json a une fonction `dump` qui sort directement dans un fichier (ou pseudo-fichier) 2. `open` en mode texte prend un encodage, donne lui le bon
Code :
with open(a_file_path, mode='w', encoding='utf-8') as f: json.dump(t, f, ensure_ascii=False)
|
Message édité par masklinn le 05-02-2018 à 12:21:07 ---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
|