I'm using Python 2.7 to convert saved tuples to list/dictionaries.
Currently my code looks like this:
mystring = "\x80\x02]q\x01(J\x03\x00\x01\x00J\x15\xf93PK\x01K\x01G@\x834\x00\x00\x00\x00\x00K\x01K\x00e}q\x02(M\x03\xbb]q\x03(U\x0bmteststringq\x04Ml0U\x05_L-A_q\x05K\x00K\x02eJ\x06M\xd1\x1d]q\x06(U\x08otherstrq"
mystruct = str(len(mystring)) + 'B'
mydict = struct.unpack(mystruct, mystring)
In reality the string is longer, I shortened it. This works for the integer values, but it contains also names like "mteststring" or "otherstr" - how do I get them out of the string along with their values?
mystringin a meaningful way, there would have to be a seperator between the elements of the tuple. Otherwise how can you distinguish anything? If you are looking for a way to save and retrieve structured information, have a look at e.g. JSON (json.org), orshelve(docs.python.org/library/shelve.html) if you don't mind that the files are not human readable.