我需要在data_list
的第二个函数中的get_data_list
函数中访问添加到get_month_averages
的新信息,但是当我尝试这样做时,它会说{{1}未定义。我该怎么做?
data_list
答案 0 :(得分:0)
这个有效:
import csv
def get_data_list():
data_file = open("table.csv", "r")
data_list = []
for line_str in data_file:
data_list.append(line_str.strip().split(','))
return data_list
def get_month_averages(data_list):
date_list = []
vol_list = []
adjclos_list = []
for row in data_list:
date_list.append(row[0])
vol_list.append(row[5])
adjclos_list.append(row[6])
all_list = [date_list, vol_list, adjclos_list]
return all_list
dList = get_data_list()
mAvg = get_month_averages(dList)
print mAvg