Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump Multiline string to toml file #421

Open
reisenmachtfreude opened this issue Apr 8, 2023 · 1 comment
Open

Dump Multiline string to toml file #421

reisenmachtfreude opened this issue Apr 8, 2023 · 1 comment

Comments

@reisenmachtfreude
Copy link

How can I dump an multi-line string to a toml file?
My approach was:

mystr = """Some
content"""
with open('dump.toml', 'w') as f:
  toml.dump({'content' : mystr}, f)

Expected output in toml file:

mystr="""Some
content"""

However, the content was automatically converted to a single line string
mystr="Some\\ncontent"

Is there any code which helps to reach my expected result?

@ZeroRin
Copy link

ZeroRin commented Apr 22, 2023

see #236 ,a custom encoder should do the trick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants