from __future__ import unicode_literals
import pymongo
import json
conn = pymongo.MongoClient(host='127.0.0.1',port=27017)
db = conn['first_db']
# print(db.collection_names())
conection = db['TestItem']
dict = {}
for i in conection.find():
for a,b,c in zip(i['author'],i['Tages'],i['content']):
dict['作者'] = a
dict['标签'] = b
dict['作品'] = c
# print(dict)
print (json.dumps(dict, ensure_ascii=False))
fp = open('output.txt', 'a+',encoding='utf8')
fp.write(json.dumps(dict, ensure_ascii=False))
fp.close()