求 Python 列表写入方法
  • 板块学术版
  • 楼主创造君
  • 当前回复7
  • 已保存回复7
  • 发布时间2021/7/22 22:35
  • 上次更新2023/11/4 13:37:31
查看原帖
求 Python 列表写入方法
372729
创造君楼主2021/7/22 22:35

为何我这样写会报错?

Python 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> a=[]
>>> a[0]=1
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    a[0]=1
IndexError: list assignment index out of range
>>> 
2021/7/22 22:35
加载中...