动态创建模块中的类对象

    xiaoxiao2023-11-15  158

    python 动态创建模块中的类对象

    import Materials """动态创建模块中的类对象""" steelName="Q235" tf=8 if steelName in dir(Materials): ip_module_cls = getattr(Materials, steelName) steel= ip_module_cls(t=tf) print(steel.__dict__) {'t': 8, 'G': 79000, 'fu': 370, 'fv': 125, 'α': 1.2e-05, 'fce': 320, 'E': 206000, 'fy': 235, 'f': 215, 'ρ': 7850}
    最新回复(0)