Mongodb创建索引.添加唯一索引.from pymongo import MongoClient # 给 coll 的 test_id 字段创建唯一索引 client = MongoClient('host', port=27017) coll = client['db']['coll'] coll.ensure_index('test_id', unique=True) 最后修改:2020 年 02 月 21 日 © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏