0
class myClass():
def filter(self, inplace = False, **kwargs):
for key, value in kwargs.items():
if isinstance(value, str):
value = "'%s'" % value
query_str += " & %s == %s" % (str(key), str(value))
myObject.filter(param1 = value1, inplace = False)
當我運行它,我得到一個錯誤信息類:
pandas.computation.ops.UndefinedVariableError: name 'param1' is not defined
我真的不明白,因爲你用**kwargs
的原因是爲了更靈活的參數,對吧?
會發生什麼事,當你運行這個命令:myObject.filter(就地=假,參數1 =值) –
的可能的複製https://stackoverflow.com/questions/36901/what-does-double-star-和星級做的參數 – Ding
可能重複[什麼\ * \ *(雙星)和\ *(星)做參數?](https://stackoverflow.com/questions/36901/what-沒有雙星和星級做的參數) – Ding