【发布时间】:2015-07-15 20:08:49
【问题描述】:
我正在尝试遍历电子表格并在其中创建一组所有列,同时将值添加到它们各自的集合中。
storage = [ set() ]*35 #there's 35 columns in the excel sheet
for line in in_file: #iterate through all the lines in the file
t = line.split('\t') #split the line by all the tabs
for i in range(0, len(t)): #iterate through all the tabs of the line
if t[i]: #if the entry isn't empty
storage[i].add(t[i]) #add the ith entry of the to the ith set
如果我为storage[0].add(t[0]) 执行此操作,它会起作用,但它会添加到存储列表中的所有集合中...为什么要这样做?我正在指定要添加到哪个集合。我没有发布 b/c 集合的打印输出是什么样子的,它太大了,但基本上每个集合都是相同的,并且包含选项卡中的所有条目
【问题讨论】: