只有用下标访问list才能修改list里面的值
# coding=gbk # 只有用下标访问list才能修改list里面的值 list = [-1, 2, 5, -8] for i in list: i += 8 print(list) for i in range(0, len(list)): list[i] += 8 print(list)
python 易错总结
原文:https://www.cnblogs.com/jkn1234/p/8903202.html