Python 官方文档:入门教程 => 点击学习
报错:TypeError: wait_assert_sql() missing 2 required positional arguments: 'assert_sql' and 'value' @propertydef wait_as
报错:TypeError: wait_assert_sql() missing 2 required positional arguments: 'assert_sql' and 'value'
@propertydef wait_assert_sql(self, assert_sql, value): print("assert_sql") print("value")
Request.wait_assert_sql(assert_sql="select", value=2)
分析原因1:
由@property 装饰后,调用函数时不需要填写参数。因为调用时,填写了参数,所以出现了报错
报错:TypeError: wait_assert_sql() missing 2 required positional arguments: 'assert_sql' and 'value'
def wait_assert_sql(self, assert_sql, value): print("assert_sql") print("value")
Request.wait_assert_sql()
分析原因2:
定义函数时,有传参,调用时也需要有传参
修改后:
def wait_assert_sql(self, assert_sql, value): print("assert_sql") print("value")
Request.wait_assert_sql(assert_sql="select", value=2)
修改如上后,可以正常执行,不会有报错
来源地址:https://blog.csdn.net/qq_41845402/article/details/128569195
--结束END--
本文标题: Python之常见报错missing 2 required positional arguments的2种问题排查方法
本文链接: https://lsjlt.com/news/406258.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0