【发布时间】:2015-10-01 12:56:18
【问题描述】:
所以我在 Python 脚本中编写了一些类,例如:
#!/usr/bin/python
import sys
import csv
filepath = sys.argv[1]
class test(object):
def __init__(self, filepath):
self.filepath = filepath
def method(self):
list = []
with open(self.filepath, "r") as table:
reader = csv.reader(table, delimiter="\t")
for line in reader:
list.append[line]
如果我从命令行调用这个脚本,我怎么能调用方法? 所以通常我输入: $ python test.py test_file 现在我只需要知道如何访问名为“方法”的类函数。
【问题讨论】:
-
再清楚一点