Python 3.6中如何使用Importlib从字符串创建类对象
我知道这类问题已经被问过好多次啦,但还是麻烦你看看我的情况~我正试着参照《将字符串转换为Python类对象》里的方法,在Python 3.6环境下通过字符串来创建类。我的utils.py代码是这样的:
class Foo(object): def __init__(self): print("In the constructor of Foo") def What(self): print("so what ... ") class FooParam(object): def __init__(self, v): self.value = v print("In the constructor of FooParam") def What(self): print("Value=" % self.value) print("So what now ...")
内容的提问来源于stack exchange,提问作者lightsunray
相关产品推荐
相关产品推荐

