When dumping a dictionary, if the value contains \n, with or without spacing around it will cause the output difference.
Is it expected? are there any way we can align the behavior?
Python 3.10.8 (main, Nov 29 2022, 21:52:51) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> d = {
... "case1": "test \n test",
... "case2": "test\ntest",
... }
>>> print(yaml.dump(d))
case1: "test \n test"
case2: 'test
test'
>>>
When dumping a dictionary, if the value contains
\n
, with or without spacing around it will cause the output difference. Is it expected? are there any way we can align the behavior?I am using
PyYAML==6.0 Python3.10.8