摘要: 一:for循环 1.1 for循环嵌套之打印99乘法表 for i in range(1,10): for j in range(1,i+1): print('%s %s=%s'%(i,j,i j),end=' ') print(' ') 1.2 for循环嵌套之打印金字塔 提示分析如下 ''' m 阅读全文
posted @ 2020-03-10 20:17 江湖有梦 阅读(265) 评论(0) 推荐(0) 编辑
摘要: 1. find.rfind,index,rindex,count 作用:找到起始索引 msg='hello world' msg.find('e') 1 rfind(反方向) ps:index与rindex的用法与find类似,但是若找不到时,find返回 1,index会异常 conut 用法:统 阅读全文
posted @ 2020-03-10 20:00 江湖有梦 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 1. strip(移除两边的符号) msg=' abc ' msg.strip( ) 'abc' 1.2 lstrip(用法和strip相同但只能移除左边的符号) 1.3 rstrip(用法和strip相同但只能移除右边的符号) 2. lower(将字符串全部转化为小写) msg.lower(msg 阅读全文
posted @ 2020-03-10 19:44 江湖有梦 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 索引: msg='hello world' 正向取 a=msg[1] 反向取 b=msg[ 1] ps:只能取不能改 切片: msg='hello world' res=msg[0:5](hello) 切片的步长: res=msg[0:5:2](hlo) 反向步长: res=msg "5:0: 1" 阅读全文
posted @ 2020-03-10 19:29 江湖有梦 阅读(706) 评论(0) 推荐(0) 编辑
摘要: int:将数字类型转化为整型 float:将数字类型转化为浮点型 str:可以将任意类型转化为字符串 使用方法: int(x) float(x) str() 阅读全文
posted @ 2020-03-10 19:25 江湖有梦 阅读(108) 评论(0) 推荐(0) 编辑
摘要: Markdown在线编辑器 www.MdEditor.com 1.什么是for循环for循环就是重复的去做某件事情,for循环是python中的第二种循环机制。2.为何要有for循环从理论上出发for循环可以做的事,while训话你都可以完成。但是for循环的循环取值(遍历取值)要比while循环更 阅读全文
posted @ 2020-03-10 19:06 江湖有梦 阅读(176) 评论(0) 推荐(0) 编辑