嘿,我正在尝试更改我的 Python 列表中的元素,但我无法让它工作。
content2 = [-0.112272999846, -0.0172778364044, 0,
0.0987861891257, 0.143225416783, 0.0616318333661,
0.99985834, 0.362754457762, 0.103690909138,
0.0767353098528, 0.0605534405723, 0.0,
-0.105599793882, -0.0193182826135, 0.040838960163,]
for i in range((content2)-1):
if content2[i] == 0.0:
content2[i] = None
print content2
它需要产生:
content2 = [-0.112272999846, -0.0172778364044, None,
0.0987861891257, 0.143225416783, 0.0616318333661,
0.99985834, 0.362754457762, 0.103690909138,
0.0767353098528, 0.0605534405723, None,
-0.105599793882, -0.0193182826135, 0.040838960163,]
我也尝试过其他各种方法。有人有想法吗?