摘要: 购物车 # __author:XY# date: 2020/3/4product=[ ('Macbook',9000), ('iphone',5000), ('ipad',3500), ('mini',2000), ('ipod',1500), ('airpods',1000), ('apple p 阅读全文
posted @ 2020-03-04 14:54 wtzxxy 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 元组 #元组内容一经建立,不可修改,故被称为只读列表#空元组,建议元组元素后加逗号,与返回值保持一致group1=()group2=(1,)print(group1,group2)#查询元组内容a=(1,2,3,4,5,6,7)print(a[1:2]) 阅读全文
posted @ 2020-03-01 20:35 wtzxxy 阅读(73) 评论(0) 推荐(0) 编辑
摘要: 列表 统计 names=['to','be','or','not','to','be']#count 统计列表中元素出现次数to=names.count('to')print(to)#extend 一个列表加到另一个列表中,列表永久改变_name_Chinese=['Zhao','Qian','Su 阅读全文
posted @ 2020-03-01 14:39 wtzxxy 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 列表,字典,元组 列表,虎头蛇尾 #列表[]#增删改查names=['alex','bill','candy','david','edison'] #列表内部索引[0,1,2,3,4,5] 查#取所有元素,相当于完整复制一份print(names[:])#取单个元素,从0开始,表示第一个print( 阅读全文
posted @ 2020-03-01 09:27 wtzxxy 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 循环 有限循环 for range(5),默认从0开始,到4结束,不包含当前显示数,相当于range(0,5) range(2,6),自定义从2开始,到5结束,不包含当前显示数 range(1,100,2),自定义从1开始,到99结束,不包含当前显示数,步长为2 break 中断,跳出当前循环 fo 阅读全文
posted @ 2020-02-29 10:35 wtzxxy 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 多行注释 '''字符串 ''' 除了用来多行注释还可以用来打印多行 占位符 %s s=string %d d=digit %f f=float 数字: 整型和浮点 布尔: 真或假 字符串: 计算机中,一切皆为对象 世界万物,皆为对象,一切对象皆可分类! 阅读全文
posted @ 2020-02-28 11:50 wtzxxy 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 倒三角 num2 = int(input("Line:"))while num2 > 0: num1 = num2 while num1 > 0: print("*",end="") num1 -=1 print() num2 -= 1 九九乘法表 first = 1while first <= 9 阅读全文
posted @ 2020-02-27 20:51 wtzxxy 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 不换行 print("Hello,world!",end='')print("Hello,world!",end='')print("Hello,world!",end='') 换行符 linux/python \n windows \r\n macOS \r print() = print(end 阅读全文
posted @ 2020-02-27 20:02 wtzxxy 阅读(104) 评论(0) 推荐(0) 编辑
摘要: while循环 while 条件 : 执行 num =1while num<=10: print(num) num+=1 1-100偶数 方法1 num =2while num<=10: print(num) num+=2 方法2 num =1while num<=100: if num%2 == 阅读全文
posted @ 2020-02-27 14:35 wtzxxy 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 把列表赋值给多个变量 a,b=[2,3] a=2 b=3 赋值运算符 num+=1 num=num+1 num-=1 num=num-1 num*=2 num=num*2 num/=2 num=num/2 num//=2 num=num//2 num%=2 num=num%2 num**=2 num 阅读全文
posted @ 2020-02-26 18:35 wtzxxy 阅读(295) 评论(0) 推荐(0) 编辑