python连接redis
import redis
import json
r = redis.StrictRedis('localhost',6379,decode_responses=True)
key = r.keys()
for value in r.sscan_iter('info'):
value = json.loads(value).get('name')
print(value)
python连接mongodb
import pymongo
client = pymongo.MongoClient(host = 'localhost',port = 27017)
db = client.user #创建user数据库
my_set = db.students #创建students集合
result = my_set.insert([{"name":"lingling","age":20,"phone":"13521386027"},{"name":"Daming","age":15,"phone":"13521385024"}])
print(result)
网友评论