![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
呦呵呦呵冲呀~~
这个作者很懒,什么都没留下…
展开
-
字符串-搜索和替换
“”" 1、字符串的搜索和替换,简单的使用str.replace()方法 2、复杂模式,使用re.sub()函数 “”" text = "yeah, but no, but yeah, but no, but yeah" print(text.replace("yeah","yes")) #text.replace()不返回值 text = 'Today is 11/27/2012. Py...原创 2019-11-07 10:07:20 · 114 阅读 · 0 评论 -
DAY3 Python作业
1.给定一个列表 L1 = [53, 40, 10, 37, 91, 97, 87, 45, 15, 12, 29, 21, 73, 77, 91, 55, 46, 64, 37, 29] 计算器平均数,并输出 from functools import reduce List1 = [53, 40, 10, 37, 91, 97, 87, 45, 15, 12, 29, 21, 73, 77, ...原创 2019-08-23 16:23:37 · 128 阅读 · 0 评论 -
DAY2,Python作业
初级题: 给定两个长度相等的列表,要求对应相加再存入第三个列表中 L1 = [1,2,3,4] L2 = [2,3,4,5] 得出L3 = [3,5,7,9] 然后输出L3 第一种方法: L3 = list(map(lambda x, y: x+y, L1, L2)) 第二种方法: L4 = [] for i in range(len(L1)): L4.append(int(L1[i]+L2[i]...原创 2019-08-22 16:07:08 · 136 阅读 · 0 评论 -
DAY1 Python作业
def list_test(): list1 = [1, 2, 3, 4, 5] list2 = [6, 7, 8, 9] list3 = [] for i in range(len(list1)): list3.append(list1[i]) list3.append(list2[i]) return list3 #print(list_test()) import re ...原创 2019-08-22 16:12:49 · 101 阅读 · 0 评论 -
DAY4 python练习
初级题 1.判断一个数是否是回文数。此题需要使用input()输入一段字符串,然后判断输入的字符串是否是回文数 输入:123321 输出:True 输入:121 输出:True 输入:24lwsr 输出:False s=input("请输入:") if s[::]==s[::-1]: print(True) else: print(False) 2.字符串旋转。对于一个字符串,我...原创 2019-08-28 15:58:05 · 176 阅读 · 0 评论 -
DAY5 python练习
“”" 请用正则表达式,找出下面字符串中所有c开头的单词, 结果是一个列表,列表里面每一个元素是一个单词’ “”" import re s = “”" And now, the end is near And so I face the final curtain My friend, I’ll make it clear I’ll state my case, of which I’m c...原创 2019-09-05 14:53:27 · 86 阅读 · 0 评论 -
DAY6 python练习
求出列表的中位数,并输出 L = [98, 78, 15, 30, 87, 36, 22, 3, 74, 61, 38, 68, 52, 10, 16, 15, 5, 39, 22, 97] def get_midian(L): L.sort(reverse=True) num = len(L) if num % 2 == 0: a, b = L[(num ...原创 2019-09-09 13:53:15 · 110 阅读 · 0 评论