def get_monthly_averages(original_list):
#print(original_list)
daily_averages_list = [ ]
for i in range (0, len(original_list)):
month_list = i[0][0:7]
volume_str = i[5]
#print(volume_str)
adj_close_str = i[6]
#print(adj_close_str)
daily_averages_tuple = (month_list,volume_str,adj_close_str)
daily_averages_list.append(daily_averages_tuple.split(','))
return daily_averages_list
我有一个类似的清单
[
['2004-08-30', '105.28', '105.49', '102.01', '102.01', '2601000', '102.01'],
['2004-08-27', '108.10', '108.62', '105.69', '106.15', '3109000', '106.15'],
['2004-08-26', '104.95', '107.95', '104.66', '107.91', '3551000', '107.91'],
['2004-08-25', '104.96', '108.00', '103.88', '106.00', '4598900', '106.00'],
['2004-08-24', '111.24', '111.60', '103.57', '104.87', '7631300', '104.87'],
['2004-08-23', '110.75', '113.48', '109.05', '109.40', '9137200', '109.40'],
['2004-08-20', '101.01', '109.08', '100.50', '108.31', '11428600', '108.31'],
['2004-08-19', '100.00', '104.06', '95.96', '100.34', '22351900', '100.34']
]
我试图从“长”列表中的每个列表中提取某些多个值。我需要使用入门 python 技术。例如,到目前为止,我们还没有在课堂上学习 lambda。必须使用入门技巧。
截至目前,使用的行i[][]
给了我一个类型错误,说'int'不可下标。