解锁式学习
1人加入学习
(0人评价)
Python基础知识-pycharm版
价格 免费
该课程属于 1991-小刘同学-算法方向-计算机视觉-就业:否 请加入后再学习

>>> #range创建整数列表
>>> range(10,1,-1)
range(10, 1, -1)
>>> list(range(10,1,-1))
[10, 9, 8, 7, 6, 5, 4, 3, 2]
>>> #留头不留尾
>>> a=x*2 for x in range(5)
SyntaxError: invalid syntax
>>> 
>>> a=[x*2 for x in range(5)]
>>> a=[x*2 for x in range(5)]
>>> a
[0, 2, 4, 6, 8]
>>> a=list(x*2 for x in range(5))
>>> a
[0, 2, 4, 6, 8]
>>> 
>>> #列表的增删会造成对列表的元素进行修改,一般只在列表的尾部添加和删除元素
>>> a=[20,40]
>>> a.append(200)
>>> a
[20, 40, 200]
>>> #这是一种推荐的元素增加方法
>>> a=a+[50]
>>> a
[20, 40, 200, 50]
>>> a.entend[50,60]
Traceback (most recent call last):
  File "<pyshell#30>", line 1, in <module>
    a.entend[50,60]
AttributeError: 'list' object has no attribute 'entend'
>>> a.extend[50,60]
Traceback (most recent call last):
  File "<pyshell#31>", line 1, in <module>
    a.extend[50,60]
TypeError: 'builtin_function_or_method' object is not subscriptable
>>> a.extend([50,60])
>>> a
[20, 40, 200, 50, 50, 60]
>>> 

[展开全文]

授课教师

高级算法工程师
老师

课程特色

图文(1)
视频(152)
考试(10)

最新学员