报错:TypeError: wait_assert_sql() missing 2 required positional arguments: 'assert_sql' and 'value'
@property
def 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:
定义函数时,有传参,调用时也需要有传参
修改后:文章来源:https://www.toymoban.com/news/detail-542413.html
def wait_assert_sql(self, assert_sql, value):
print("assert_sql")
print("value")
Request.wait_assert_sql(assert_sql="select", value=2)
修改如上后,可以正常执行,不会有报错文章来源地址https://www.toymoban.com/news/detail-542413.html
到了这里,关于Python之常见报错missing 2 required positional arguments的2种问题排查方法的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!