python 所有实例成员 用什么方法能全部显示出来
展开全部
class A:
def __init__(self):
pass
a1=a2=a3=a4=A()
instances_of_A = []
for value in globals().values():
if isinstance(value,A):
instances_of_A.append(value)
#instances_of_A is a list containing all instances of A in global scope.
def __init__(self):
pass
a1=a2=a3=a4=A()
instances_of_A = []
for value in globals().values():
if isinstance(value,A):
instances_of_A.append(value)
#instances_of_A is a list containing all instances of A in global scope.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询