2012-05-18 7 views
10

Ich versuche, eine Reihe von UTF-8-codierten Strings zu laden und sie erneut mit PyYaml ablegen. Dies ist der Code für das Laden/Dumping:Dump in PyYaml als 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')) 

Aber ein Zeichenfolgen, die als "En arrière" Start endet als gespeichert als "En arri \ xE8re". Was mache ich falsch?

Antwort