试图模拟Counter,得到TypeError:' str'对象不可调用

时间:2016-01-28 07:08:24

标签: python python-2.5

我希望根据多个密钥获取重复记录。我使用的是Python 2.5,因此我无法使用public class Test { public static void main(String args[]) { String s1 = "0X11XXXXX000000000000000000000000000000000000000000000000X000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011"; String s2= "0111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011"; char a[] = s1.toCharArray(); int i = s1.indexOf('X', 0); while(i!=-1) { while(a[i] == 'X'){ a[i] = s2.charAt(i); i++; } i = s1.indexOf('X',i+1); } s1 = new String(a); System.out.println("result: "+s1); } } 。我正在更改代码以获得我想要的结果,但我得到的是Counter

TypeError: 'str' object is not callable

1 个答案:

答案 0 :(得分:1)

所以你换了rowkey

for row in file2:
    if key(row) not in f:
        f.append(row)