Exemplo n.º 1
0
def addQuestion(qId: str, answer: Answer):
    answer.aId = str(uuid.uuid1())
    data = answer.__dict__
    data["author"] = answer.author.__dict__
    for question in qaDb["questions"]:
        if question["qId"] == qId:
            question["answerList"].append(data)
    with open('qaDb.json', 'w') as f:
        f.write(json.dumps(qaDb, indent=4, sort_keys=True))
    return True