任何想法,爲什麼當我打電話:通過索引替換python列表中的項目..失敗?
>>> hi = [1, 2]
>>> hi[1]=3
>>> print hi
[1, 3]
我可以通過它的索引更新列表項,但是當我打電話:
>>> phrase = "hello"
>>> for item in "123":
>>> list(phrase)[int(item)] = list(phrase)[int(item)].upper()
>>> print phrase
hello
它失敗了呢?
應該hELLo
好的回答:) +1 –
@InbarRose謝謝:)。 – TerryA