![](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 · 112 阅读 · 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 reduceList1 = [53, 40, 10, 37, 91, 97, 87, 45, 15, 12, 29, 21, 73, 77, ...原创 2019-08-23 16:23:37 · 124 阅读 · 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 · 133 阅读 · 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 · 93 阅读 · 0 评论 -
DAY4 python练习
初级题1.判断一个数是否是回文数。此题需要使用input()输入一段字符串,然后判断输入的字符串是否是回文数输入:123321输出:True输入:121输出:True输入:24lwsr输出:Falses=input("请输入:")if s[::]==s[::-1]: print(True)else: print(False)2.字符串旋转。对于一个字符串,我...原创 2019-08-28 15:58:05 · 168 阅读 · 0 评论 -
DAY5 python练习
“”"请用正则表达式,找出下面字符串中所有c开头的单词,结果是一个列表,列表里面每一个元素是一个单词’ “”"import res =“”"And now, the end is near And so I face the final curtain My friend, I’ll make it clearI’ll state my case, of which I’m c...原创 2019-09-05 14:53:27 · 84 阅读 · 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 · 107 阅读 · 0 评论