def updateTheme(self, id, new_theme): theme = Theme.query.filter_by(id = id).first() theme.update(new_theme) db.session.commit()錯誤:“主題”對象沒有屬性“更新”這是它應該如何工作:theme = Theme(name = "osman")new_theme = Theme(name = "miras")theme.update(new_theme)print(theme) # osman have to be changed to miras即使我可以這樣做:theme.name = "miras"當我必須使用多個參數時,如姓名、姓氏、電話。此外,updateTheme 并不總是提供所有參數(姓名、姓氏、電話),它應該只更新提供的參數。例如:person = {name: "john", surname: "smith", phone: 12345, country: "USA"}update_person = {country: "Portugal"}person.update(update_person) # should change only country
添加回答
舉報
0/150
提交
取消