2012-05-18 7 views
10

Sto provando a caricare un gruppo di stringhe codificate in utf-8 e le scarico di nuovo con PyYaml. Questo è il codice per il caricamento/scarico:Dump in PyYaml come utf-8

lang_yml = yaml.load(codecs.open(lang + ".yml.old", "r", "utf-8")) 
test_file_path = lang + '.yml' 
stream = file(test_file_path, 'w') 
yaml.dump(lang_yml, stream, default_flow_style=False, encoding=('utf-8')) 

Ma a stringhe che iniziano come "En arrière" finisce per essere salvato come "En Arri \ xE8re". Cosa sto sbagliando?

risposta