from database import db
db_list = ["table1", "table2", "table3", "table4"]
for item in db_list:
collection = db[item]
collection.create_index([("phone", 1)])
print(list(collection.index_information()))
转载于:https://www.cnblogs.com/c-x-a/p/9836501.html
相关资源:pymongo为mongodb数据库添加索引的方法