import numpy as np
class MyClass:
a = int()
b = float()
c = np.array([0 for i in range 10])
def Memberfunction():
print("Hii")
答案 0 :(得分:0)
class test_class():
def __init__(self, some_func):
self.some_value = 2
setattr(type(self), some_func.__name__, some_func)
def my_requested_func(self):
print(self.some_value)
class_instance = test_class(my_requested_func)
class_instance.my_requested_func()
这应该有用,但我没有看到你想要这样做的任何理由。