随笔分类 -  python笔记

摘要:语法 replace()方法语法: str.replace(old chr, new chr, max) new chr:需要替换的字符 max:字符串替换次数不超过 max 次,如不填写的话则将str中所有old字符替换为new字符 参考链接:https://www.cnblogs.com/zho 阅读全文
posted @ 2020-05-13 17:30 Y鱼鱼鱼Y 阅读(2131) 评论(0) 推荐(0) 编辑
摘要:s = ''.join(a.split()) join方法: 参考链接:https://www.runoob.com/python3/python3-string-join.html 阅读全文
posted @ 2020-05-13 17:11 Y鱼鱼鱼Y 阅读(709) 评论(0) 推荐(0) 编辑
摘要:基本格式: 参考链接:https://www.icourse163.org/spoc/learn/SYXY-1456795163?tid=1457185442#/learn/content?type=detail&id=1231788053 阅读全文
posted @ 2020-05-13 17:06 Y鱼鱼鱼Y 阅读(155) 评论(0) 推荐(0) 编辑
摘要:简单地讲,yield 的作用就是把一个函数变成一个 generator,带有 yield 的函数不再是一个普通函数,Python 解释器会将其视为一个 generator,调用带有它的函数不会执行函数,而是返回一个 iterable 对象!在 for 循环执行时,每次循环都会执行 even_numb 阅读全文
posted @ 2020-05-06 12:27 Y鱼鱼鱼Y 阅读(1180) 评论(0) 推荐(0) 编辑
摘要:使用map函数 python3.x,map返回的是map对象,当然也可以转换为List: list1 = list(map(int, list1)) 输入时去除空格元素: list1 = list(input().split(' ')) 列表去除空格元素: list1 = [x for x in l 阅读全文
posted @ 2020-04-30 16:40 Y鱼鱼鱼Y 阅读(777) 评论(0) 推荐(0) 编辑
摘要:在新民主主义社会中,居于领导地位的是 阅读全文
posted @ 2020-04-14 18:18 Y鱼鱼鱼Y 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2020-04-12 21:24 Y鱼鱼鱼Y 阅读(4824) 评论(0) 推荐(0) 编辑
摘要:python3.x版本使用print('输出内容', end='')这种方式。 示例: s='abc' print(s[0]) print(s[:1],end='')//输出ab,未输出换行 print(s[2])//输出c 输出结果: a abc 阅读全文
posted @ 2020-04-08 15:25 Y鱼鱼鱼Y 阅读(375) 评论(0) 推荐(0) 编辑