getattr(cbobj,funcname)(*args)
时间: 2023-12-19 16:04:31 浏览: 150
简单了解python反射机制的一些知识
This line of code will call a function named `funcname` on an object `cbobj` and pass in any arguments provided in the `args` parameter.
`getattr` is a built-in Python function that takes two parameters - an object and a string representing the name of an attribute or method of that object. The function returns the value of that attribute or calls the method on the object.
In this case, `funcname` is a string variable containing the name of a method on the `cbobj` object. The `getattr` function retrieves the method with that name from the object and calls it, passing in any arguments provided in the `args` parameter.
阅读全文