from pymongo import MongoClient from bson import ObjectId def bid_score(): db = MongoClient('192.168.3.167', 27080, unicode_decode_error_handler="ignore").jyqyfw_historyData2023_1 coll_user = db["20230921Ssk_endo"] # db = MongoClient('192.168.3.166', 27082, unicode_decode_error_handler="ignore").yantianlei # coll_user = db["20230920Zglt_9_1"] # db = MongoClient('192.168.3.166', 27082, unicode_decode_error_handler="ignore").zhaoxiuzhen # coll_user = db["20230917LT_ycl"] count=0 score=100 # for item in coll_user.find({"_id":ObjectId("64dc2bea5b7b9126edac6845")}): for item in coll_user.find().sort("_id",1): # if item['title_qa']: # score-=10 if item['projectname_qa']: score-=10 if item['area_qa']: score-=10 if item['projectcode_qa']: score-=10 # if item['bidopentime_qa']: # score-=10 if item['buyer_qa']: score-=10 if item['winner_qa']: score-=10 if item['budget_qa']: score-=10 if item['bidamount_qa']: score-=10 if item["multipackage_qa"]: score -= 10 print(score) coll_user.update_one({"_id": item["_id"]}, {"$set": {"score": score}}) score = 100 bid_score()