How to serialize hash objects in Python
问题 How can I serialize hash objects?, I'm using shelve to store a lot of objects. Hierarchy: - user - client - friend user.py: import time import hashlib from localfile import localfile class user(object): _id = 0 _ip = "127.0.0.1" _nick = "Unnamed" _files = {} def __init__(self, ip="127.0.0.1", nick="Unnamed"): self._id = hashlib.sha1(str(time.time())) self._ip = ip self._nick = nick def add_file(self, localfile): self._files[localfile.hash] = localfile def delete_file(self, localfile): del