为了账号安全,请及时绑定邮箱和手机立即绑定

无法识别 Python 的函数 update()

无法识别 Python 的函数 update()

海绵宝宝撒 2021-09-14 10:32:28
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
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 169 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号