我有一个列表,如:
y=['1997,05,22', '1997,05,21', '1997,05,20', '1997,05,19', '1997,05,16', '1997,05,15'........]
我尝试使用.format
更改列表的fotmat,如:
[new Date(1997,05,22),new Date(1997,05,21),new Date(1997,05,20),...]
首先我尝试
y2 = []
for i in y:
z = 'new Date({0},{1},{2})'.format(*i)
y2.append(z)
以获取[new Date(1997,05,22),...]
之类的列表,但输出如下:
['new Date(1,9,9)', 'new Date(1,9,9)', 'new Date(1,9,9)', 'new Date(1,9,9)', 'new Date(1,9,9)', 'new Date(1,9,9)']
任何想法? Thansk!