你会在网上找到很多很棒的oopython教程,比如here或here。在
获取函数的返回值return_value = my_function(my_argument)
例如,通过在命令行上运行python来使用解释器:
^{pr2}$
清除代码:
你的代码没有意义。在什么是nmaidcount().finallist?在
你在程序中的什么地方定义finallist?在
为什么你有if True?永远都是这样!在
我想你的意思是:tsvs = glob.glob(sys.argv[1])
class StatFind:
# This is the instance initialiser.
def __init__(self,tsvs):
self.tsvs=tsvs
# here we define every instance of StatFind to have an attribute
# called 'finallist' which will be accessible by all methods
self.finallist = []
# We do our initialisation here, when we initialise our object,
# instead of in a separate method.
for path in self.tsvs:
finalist.append(do_something(path))
def inserttomongo(self):
# The 'self'