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 · 655 阅读 · 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] = 8print(c)print(c[-1])print("————————这是一个分割线————————")for i in c: print(i)print("————————这是一个分割线————————")index = 0while inde.原创 2022-05-24 13:32:31 · 480 阅读 · 0 评论 -
python循环
一.while1.while:条件语句判断为真继续,判断为假结束2.while:True恒为真,无限循环,需结合break;countine二.forfor () in ()1.可以循环列表,字符串2.添加range();中间调数值范围左闭右开如range(1,8,2)从1开始,到8结束(但不包括8),间隔为2三.其他1.countine跳出本次循环2.break结束循环3.循环内可以嵌套循环...原创 2022-05-11 00:14:52 · 135 阅读 · 0 评论