I am trying to pass argument to a function in this fashion
GroupGeneralConfig(selectedGroup = "Group1")
and the function looks like this...
def GroupGeneralConfig(self, *args)
img = str(args[0]) + "abc"
whenever i execute this program it is throwing like this...
TypeError: GroupGeneralConfig() got an unexpected keyword argument 'selectedGroup'
whats wrong here
You'll want the double star :
def GroupGeneralConfig(self, **kwargs):
img = str(kwargs[selectedStreamGroup]) + "abc"
如果要使用kwargs
,则应先定义它:
def GroupGeneralConfig(self, **kwargs):
What you are passing in is a keyword argument, change your method to accept keyword arguments first. Like this
def GroupGeneralConfig(self, *args, **kwargs)
img = str(args[0]) + "abc"
Then you can pass the arguments first and then the keyword arguments, like:
GroupGeneralConfig(arg_x, arg_y, kwarg_x=1, kwarg_y=2)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.