我需要将一个Object转换为Arraylist:
with open("path/to/input") as infile, open("path/to/output", 'w') as outfile:
months = {}
for line in infile:
month, val = line.strip().split(',')
val = float(val)
month = month[:3]
if month not in months:
months[month] = 0
months[month] += val
for month in 'jan feb mar apr may jun jul aug sep oct nov dec'.split():
outfile.write(','.join([month, str(months[month])))
答案 0 :(得分:2)
假设它是ArrayList
,你可以投了它(我推荐List
界面)
List<Products> mypr = (List<Products>) sesion.getAttribute("products");