小编Chr*_*ott的帖子

TypeError:'filter'对象不可订阅

我收到了错误

TypeError: 'filter' object is not subscriptable
Run Code Online (Sandbox Code Playgroud)

尝试运行以下代码块时

bonds_unique = {}
for bond in bonds_new:
    if bond[0] < 0:
        ghost_atom = -(bond[0]) - 1
        bond_index = 0
    elif bond[1] < 0:
        ghost_atom = -(bond[1]) - 1
        bond_index = 1
    else: 
        bonds_unique[repr(bond)] = bond
        continue
    if sheet[ghost_atom][1] > r_length or sheet[ghost_atom][1] < 0:
        ghost_x = sheet[ghost_atom][0]
        ghost_y = sheet[ghost_atom][1] % r_length
        image = filter(lambda i: abs(i[0] - ghost_x) < 1e-2 and
                       abs(i[1] - ghost_y) < 1e-2, sheet)
        bond[bond_index] = old_to_new[sheet.index(image[0]) + …
Run Code Online (Sandbox Code Playgroud)

python python-idle

29
推荐指数
2
解决办法
3万
查看次数

标签 统计

python ×1

python-idle ×1