import pymongo myclient = pymongo.MongoClient('localhost', 27017) # 连接MongoDB db = myclient['temp_user_info'] DataYuan = db['qqandtel'] DataResult = db["result"] # DataYuan.insert_one({"姓名":"小明","年龄":9}) print(DataYuan.find_one({"姓名":"小明"})["年龄"])