I am trying to dump this string with space at the end:
-----
ooooo
-----
to a pickle file(.pkl.txt). But while dumping I get this:
"€♦•▬ Œ↕-----
ooooo
-----
”."
How do I make it to dump the initial string?
I am trying to dump this string with space at the end:
-----
ooooo
-----
to a pickle file(.pkl.txt). But while dumping I get this:
"€♦•▬ Œ↕-----
ooooo
-----
”."
How do I make it to dump the initial string?
Can you share some code that shows this problem? It is hard to know what’s going on without some code to look at.
a = ['-', '-', '-', '-', '-', '\n', 'o', 'o', 'o', 'o', 'o', '\n', '-', '-', '-', '-', '-', '\n']
sep = ''
b = sep.join(a)
with open('pickled.pkl.txt', 'wb') as f:
pickle.dump(b, f)
I think the extra characters you are seeing are probably the information Python needs to read this back into an object.
If you want to only write the string, I’d use open()
, .write()
, and .close()
.
Thanks a lot! That was actually the way to solve the issue.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.