[Pickle]dirty problem 3 lines

MRAB python at mrabarnett.plus.com
Tue Aug 31 23:23:57 EDT 2010


On 01/09/2010 03:33, bussiere bussiere wrote:
> i know it's dirty, i know i should use json but i want to know, it's
> quiet late here :
> import pickle
> dump = """b'\x80\x03]q\x00(K\x00K\x01e.'"""
> print(pickle.loads(dump))
>
> how can i get back my object from this string ?
> the string is :  b'\x80\x03]q\x00(K\x00K\x01e.'
> and i'am using python3
> help will be appreciated i'am chewing on this for a long time now.

Well, pickle.loads(b'\x80\x03]q\x00(K\x00K\x01e.') works.

That, of course, is not the same as """b'\x80\x03]q\x00(K\x00K\x01e.'""".

Do you mean r"""b'\x80\x03]q\x00(K\x00K\x01e.'"""?

(It's also late here, well, actually, so late it's early... Time to
sleep. :-))



More information about the Python-list mailing list