>我正在编写一个函数load_data
,没有输入也没有返回,它只是从url读取数据集并拆分数据集。如果我想调用函数load_data()
,如果我在其他地方调用load_data()
,如何存储这两个数据集?
提前谢谢。
您可以为处理数据执行的任何操作定义一个类load_data()
并且必须是将数据存储到类变量的类的函数。
class MyDataClass:
def __init__(self):
self.data = None
def load_data(self):
self.data = # put your data stuff here