如果我想将两个文件中的记录存储到一个表(一个记录数组)中,是否可以使用类似于下面代码的格式,将两个文件名都放入def readTable(log1,log2)这样的def函数中:然后对log1和log2使用相同的代码,这样就可以生成table1和table2?你知道吗
def readTable(fileName):
s = Scanner(fileName)
table = []
record = readRecord(s)
while (record != ""):
table.append(record)
record = readRecord(s)
s.close()
return table
由于
readTable
返回一个列表,因此如果要连接两个日志中的记录,请使用+
运算符。你知道吗只需使用*args,并获取记录列表?你知道吗
这样,您就可以传递log1、log2、log3(任意数量的日志),并为每个日志返回一个表列表
相关问题 更多 >
编程相关推荐