【发布时间】:2018-08-25 00:32:08
【问题描述】:
我要转换这个
1:a,b,c
2:d,e,f
进入这个
[[1, ['a', 'b', 'c']],[2, ['d', 'e', 'f']]]
我的代码
letters = open("letters.txt")
alist = []
for line in favmovies:
line = line.strip().split(":")
line[0] = int(line[0])
alist.append(line)
但它却给出了这个
[[1, 'a,b,c'], [2, 'd,e,f']]
谁能提供解决方案?
【问题讨论】:
标签: python string list integer