我需要帮助,不知道我做错了什么。我一直收到这个错误,我不确定为什么有人能给我任何建议:
TypeError: find_one_and_update() missing 1 required positional argument: 'update'
以下是我的测试代码:
import pymongo
from pymongo import ReturnDocument
import datetime
from animalsCRUD import AnimalShelter
#username = "aacuser"
#password = "password"
insertRec = AnimalShelter("aacuser", "password")
locateRec = AnimalShelter("aacuser", "password")
updateRec = AnimalShelter("aacuser", "password")
deleteRec = AnimalShelter("aacuser", "password")
animal = ({"age_upon_outcome":"5 years", "animal_id":"A333333", "animal_type":"Dog",
"breed":"Derp", "color":"White",
"date_of_birth":"07/19/19", "datetime": datetime.datetime.now(), "name":"",
"outcome_subtype":"Foster",
"outcome_type":"Adoption", "sex_upon_outcome":"Intact Female", "location_lat":30.60784677,
"location_long":-97.35087807, "age_upon_outcome_in_weeks":64.24642857})
critter = {"animal_id":"A333333"}
changeCritter = ({"animal_id": "A333333"}, {'$set': {'animal_type': 'Cat'}})
print(insertRec.create(animal))
locateRec.locate(critter)
updateRec.update(changeCritter)
locateRec.locate(critter)
deleteRec.delete(critter)
发布于 2021-01-16 00:59:23
update方法有两个参数,您可以分解元组
updateRec.update(changeCritter[0],changeCritter[1])
https://stackoverflow.com/questions/65745397
复制相似问题