我希望根据多个键获取重复记录。我使用的是 Python 2.5,因此无法使用 Counter
。我正在更改代码以获得所需的结果,但收到 TypeError: 'str' object is not callable
。
start ="0,1,2,3"
mylist= [int(x) for x in start.split(',')]
key = itemgetter(*mylist)
file2 = open('temp_src.csv','rb')
f=[]
for row in file2:
if row(key) not in f: error
f.append(row)
最佳答案
所以你交换了行
和键
:
for row in file2:
if key(row) not in f:
f.append(row)
关于python - 尝试模拟 Counter,收到 TypeError : 'str' object is not callable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35054897/