# method def func(n): l = [] for i in range(n): l.append({ "name":"name"+str(i+1), "id":str(1300+i+1) }) return l # result func(3) [{'name': 'name1', 'id': '1301'}, {'name': 'name2', 'id': '1302'}, {'name': 'name3', 'id': '1303'}]
Permalink | 記事への反応(0) | 01:46
ツイートシェア