
python
python
雪I霁
这个作者很懒,什么都没留下…
展开
-
python切片
一、切片结构: object[start:end:step] 注: 1、step:可以为负,默认方向是从左往右,负数代表从右往左(导致倒序) (如果start:end和step矛盾则返回为空列表) 2、start,从0开始 3、类似range;start闭end开 二、特殊(默认x = [0,1,2,3,4,5,6,7,8,9]) 1、输出全部元素 x[:] 2、未给step值,默认方...原创 2022-05-26 21:42:47 · 703 阅读 · 0 评论 -
python列表
d = [] a = [1,2,3,4] print(type(a)) b = list() print(type(b)) c = list([1,2,3,4,5,6]) print(type(c)) print(c[4]) c[4] = 8 print(c) print(c[-1]) print("————————这是一个分割线————————") for i in c: print(i) print("————————这是一个分割线————————") index = 0 while inde.原创 2022-05-24 13:32:31 · 663 阅读 · 0 评论 -
python循环
一.while 1.while:条件语句 判断为真继续,判断为假结束 2.while:True 恒为真,无限循环,需结合break;countine 二.for for () in () 1.可以循环列表,字符串 2.添加range();中间调数值范围左闭右开 如range(1,8,2)从1开始,到8结束(但不包括8),间隔为2 三.其他 1.countine 跳出本次循环 2.break 结束循环 3.循环内可以嵌套循环 ...原创 2022-05-11 00:14:52 · 163 阅读 · 0 评论