Open monkeydone opened 7 years ago
import sys print sys.modules['redis']
import redis conn = redis.Redis('localhost')
user = {"Name":"Pradeep", "Company":"SCTL", "Address":"Mumbai", "Location":"RCP"}
conn.hmset("pythonDict", user)
conn.hgetall("pythonDict")
{'Company': 'SCTL', 'Address': 'Mumbai', 'Location': 'RCP', 'Name': 'Pradeep'}
import pickle import redis
r = redis.StrictRedis('localhost') mydict = {1:2,2:3,3:4} p_mydict = pickle.dumps(mydict) r.set('mydict',p_mydict)
read_dict = r.get('mydict') yourdict = pickle.loads(read_dict)
打印库路径
python -c "import sys;print sys.path"
两个list之差
list(set(a)-set(b))