Итак, вот мой базовый пример :
Код: Выделить всё
import yaml
error = {"Test": {"error": repr('Yaml is working')}}
print(f"{error = }")
with open("yaml_repr_pass_test.yaml", "w") as file:
file.write(yaml.dump(error, default_flow_style=False))
Код: Выделить всё
Test:
error: '''Yaml is working'''
Код: Выделить всё
import yaml
error = {"Test": {"error": repr("Yaml 'is not' working")}}
print(f"{error = }")
with open("yaml_repr_fail_test.yaml", "w") as file:
file.write(yaml.dump(error, default_flow_style=False))
Код: Выделить всё
Test:
error: '"Yaml ''is not'' working"'
Подробнее здесь: https://stackoverflow.com/questions/790 ... des-string