复制代码 代码如下:def ReadOnlyObject(**args): dictBI = {} args_n = [] for name, val in args.items(): dictBI[name] = val args_n.append(name) dictBI[‘__slots__’] = args_n return type(‘ReadOnlyObject’, (object,), dictBI)() 您可能感兴趣的文章:Python中动态获取对象的属性和方法的教程pyt