def func_class(string):
if string == 'class_one':
class class_one:
pass
return class_one
else:
class class_two:
pass
return class_two
MyClass = func_class('')
print("MyClass为 " , MyClass)
m = MyClass()
print("m为 ",m)
'''
MyClass为 <class '__main__.func_class.<locals>.class_two'>
m为 <__main__.func_class.<locals>.class_two object at 0x000002BC0491B190>
'''
2020-05-08