I ´m trying to serialize an array in python to insert it on a database of MySQL... I try with pickle.dump() method but it returns byte... what can I use?? thanks!!
(I ´m working in python 3)
You can try to use json to turn it into a string, like this:
import json
v = [1, 2, 4]
s = json.dumps(v)
Pickle is a binary serialization, that's why you get a byte string.
Pros:
Con's:
JSON is more universal, so you're not tied to reading data with Python. It's also mostly ASCII, so it's easier to handle. the con is that it's limited to numbers, strings, arrays and dicts. usually enough, but even datetimes have to be converted to string representation before encoding.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With