直接通过索引修改
```python
array = [1, 2, 3, 4, 5]
index = 2
new_value = 10
array[index] = new_value
print(array) 输出:[1, 2, 10, 4, 5]
使用切片修改
```python
array = [1, 2, 3, 4, 5]
new_slice = array[1:3]
new_slice = 10
array[1:3] = new_slice
print(array) 输出:[1, 10, 3, 4, 5]
使用列表推导式修改
```python
array = [1, 2, 3, 4, 5]
array = [new_value if i == index else value for i, value in enumerate(array)]
print(array) 输出:[1, 2, 10, 4, 5]
使用循环遍历数组修改
```python
array = [1, 2, 3, 4, 5]
for i in range(len(array)):
if array[i] == index:
array[i] = new_value
print(array) 输出:[1, 2, 10, 4, 5]
使用NumPy库修改
```python
import numpy as np
array = np.array([1, 2, 3, 4, 5])
index = 2
new_value = 10
array[index] = new_value
print(array) 输出:[1, 2, 10, 4, 5]
以上是几种常见的方法来改变Python中数组的值。请根据你的具体需求选择合适的方法