05 2022 档案

摘要:#匿名函数def isodd(x): return x%2a=isodd(10)print(a)isodd = lambda x: x%2#无参数#func= lambda:3,14#func()#print(a)myadd = lambda x,y:x+yA=myadd(1,2)print(A)m 阅读全文
posted @ 2022-05-28 12:26 人生信条~~ 阅读(26) 评论(0) 推荐(0) 编辑
摘要:#!/bin/bashlogApi=(91xingcai xinyao ag ah ascp)for i in ${logApi[*]};do content=`tail -n 100000 /home/logs/nginx/access/${i}Api.log |grep -v 'upstream 阅读全文
posted @ 2022-05-27 17:37 人生信条~~ 阅读(84) 评论(0) 推荐(0) 编辑
摘要:#作用域#匿名函数def isodd(x): return x%2a=isodd(10)print(a)isodd = lambda x: x%2#无参数#func= lambda:3,14#func()#print(a)myadd = lambda x,y:x+yA=myadd(1,2)print 阅读全文
posted @ 2022-05-27 12:23 人生信条~~ 阅读(25) 评论(0) 推荐(0) 编辑
摘要:#csv文件:使用纯文本来存储表格数据 并以分隔符进行分隔#1.导入模块 import csv#2.打开文件 创建csv对象# f=open(fname)# csvf=csv.reader(f)#3.for row in csvf: print(row)#4.关闭文件 f.close()# impo 阅读全文
posted @ 2022-05-25 08:05 人生信条~~ 阅读(200) 评论(0) 推荐(0) 编辑
摘要:#文件读取path=r'D:\Python学习\day1\a.txt'f=open(path,encoding='utf-8')print(f)txt=f.read()print(txt)f.close()#文件写入# path=r'D:\Python学习\day1\a.txt'# f=open(p 阅读全文
posted @ 2022-05-24 02:13 人生信条~~ 阅读(33) 评论(0) 推荐(0) 编辑
摘要:eventlist=[]def genEvent(): 'return event' event={} keys = ['时间','地点','事件'] for key in keys: msg = input(f'enter {key}') event.setdefault(key,msg) ret 阅读全文
posted @ 2022-05-23 01:45 人生信条~~ 阅读(28) 评论(0) 推荐(0) 编辑
摘要:#列表解析+判断语句求偶数# print([i for i in range(1,101) if i %2==0])import randommath_report=[random.randint(0,100) for i in range(20)]chinese_report=[random.ra 阅读全文
posted @ 2022-05-22 23:41 人生信条~~ 阅读(35) 评论(0) 推荐(0) 编辑
摘要:#1.统计小写英文字符出现的次数def countchrnum(s): result={} for c in s: if c < 'a' or c > 'z':# 判断字母c < a 或者 c >z continue if c in result: result[c] += 1 else: resu 阅读全文
posted @ 2022-05-22 19:11 人生信条~~ 阅读(178) 评论(0) 推荐(0) 编辑
摘要:#字典详解d={'a':'98','b':'97'}a=dict(x=10,y=20) #创建对象b=((('x',90),'y',100))s1='abc's2='123'print(dict(zip(s1,s2)))print(dict.fromkeys(s1,-1))print(a,b)pri 阅读全文
posted @ 2022-05-22 17:19 人生信条~~ 阅读(28) 评论(0) 推荐(0) 编辑
摘要:#冒泡排序list1=[3,2,4,1,5,0]#外部def bubblesort(l): for end in range(len(list1)-1): #内部两两交换位置 循环,len(list1)-end-1 for index in range(len(list1)-end-1): if l 阅读全文
posted @ 2022-05-22 15:29 人生信条~~ 阅读(19) 评论(0) 推荐(0) 编辑
摘要:#列表切片操作l=list(range(10))print(l)A=sum(l)print(A)object=zip('123','345')for item in object: print(item)#1.插入元素list1=[]list1.append(1)list1.append('1')p 阅读全文
posted @ 2022-05-13 19:02 人生信条~~ 阅读(25) 评论(0) 推荐(0) 编辑
摘要:#解析手机价格prices='荣耀v20:1899,xiaomiMax3:2599,vivoz5:1648'#函数接口 及返回值 不需要返回def parsePhonePrice(pricelist): step1=prices.split(',') #['荣耀v20:1899', 'xiaomiM 阅读全文
posted @ 2022-05-09 15:41 人生信条~~ 阅读(18) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示