I know it is possible to encode a Python object to a file using
import pickle
pickle.dump(obj, file)
or you can do nearly the same using JSON, but the problem is, these all encode or decode to a file, is it possible to encode an object into a string or bytes variable instead of a file?
I am running Python 3.2 on windows.
Sure, just use
pickle.dumps(obj)orjson.dumps(obj).