1. 程式人生 > >python 易錯總結

python 易錯總結

pre int python span 問題 修改 bsp style AS

  • list的遍歷問題:
    只有用下標訪問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 易錯總結