Python 'called with the wrong argument type' error

后端 未结 1 965
[愿得一人]
[愿得一人] 2021-01-22 05:46

I understand why I am getting this error, it\'s looking for my object as an argument, and receiving a string value. But I\'m confused as to what the solution would be?

T

1条回答
  •  囚心锁ツ
    2021-01-22 06:16

    The problem is that button is a string, a possible solution is to use getattr.

    Change:

    button = "self.ui."+prefix+numString
    

    to

    button = getattr(self.ui, prefix+numString)
    

    0 讨论(0)
提交回复
热议问题