pickling error in python?

前端 未结 5 694
情歌与酒
情歌与酒 2021-01-07 21:20

I am getting this error, and I dont know what it means. How can I fix this problem?

my code looks like this, I\'ve used it before and it has worked:



        
5条回答
  •  春和景丽
    2021-01-07 21:37

    This exact error occurred for me when I tried to unpickle (using pickle.loads) a string representation that I had stored in a database via django. Django changed the charactee representation of my string so that pickle.loads(mystring) threw me that error. When I added an explicit string conversion in, it was fine: pickle.loads( str(mystring) )

    EDIT: looking at the comments on the original post, I think this is related to the unicode string issue mentioned. I put a normal string into the database, and django gives me back a unicode string that produces this error.

提交回复
热议问题