__director

2020年4月25日

行列互换

摘要: [root@xiaoyuan ~]# cat file0081 2 34 5 67 8 9[root@xiaoyuan ~]# awk '{for(i=1;i<=NF;i++)a[i]=a[i]$i" "}END{for(x in a)print a[x]}' file0081 4 7 2 5 8 阅读全文

posted @ 2020-04-25 21:05 __director 阅读(92) 评论(0) 推荐(0) 编辑

毕业毕业

摘要: 只求一offer 阅读全文

posted @ 2020-04-25 17:28 __director 阅读(93) 评论(0) 推荐(0) 编辑

列表去重

摘要: listA = [2,2,5,5,45,3,1,3] listB = [2,2,5,5,45,3,1,3] listC = [2,2,5,5,45,3,1,3] #法一:set print(list(set(listA))) #法二 tmp = [] for i in listB: if i not 阅读全文

posted @ 2020-04-25 17:10 __director 阅读(59) 评论(0) 推荐(0) 编辑

两个列表引索相同元素相加

摘要: listA = [1,2,3,4] listB = [8,7,6,5] listC = list(zip(listA,listB)) print(listC) listD = [x+y for x ,y in listC] print(listD) 阅读全文

posted @ 2020-04-25 17:00 __director 阅读(217) 评论(0) 推荐(0) 编辑

合拼两个有序列表

摘要: listA = [1,2,5,9,34,99] listB = [3,6,15,59,88] def fun(arg1,arg2): tmp = [] while len(arg1) > 0 and len(arg2) > 0: if arg1[0] > arg2[0]: tmp.append(ar 阅读全文

posted @ 2020-04-25 16:49 __director 阅读(72) 评论(0) 推荐(0) 编辑

遍历目录

摘要: import os n = m = count =0 list_05 = [] def fun(argument): for i in os.listdir(argument): doucument = os.path.join(argument,i) if os.path.isdir(doucum 阅读全文

posted @ 2020-04-25 16:02 __director 阅读(122) 评论(0) 推荐(0) 编辑

shell 随机产生字符串或数字

摘要: 产生字符串:法一:echo $RANDOM |md5sum |cut -c 1-6 #这里是产生6位,可以有1-32位 法二: cat /proc/sys/kernel/random/uuid |cut -c 1-8 ed9e032c #这里是产生8位,可以有1-36位 产生数字 法一:date + 阅读全文

posted @ 2020-04-25 15:51 __director 阅读(377) 评论(0) 推荐(0) 编辑

判断三点能否构成三角形

摘要: listA = [(2,3),(3,5),(5,7)] listB = [(1,2),(2,4),(4,8)] def tri(arg): x0,y0 = arg[0] x1,y1 = arg[1] x2,y2 = arg[2] if (y0-y1)*(x0-x2) == (y0-y2)*(x0-x 阅读全文

posted @ 2020-04-25 15:26 __director 阅读(1034) 评论(0) 推荐(0) 编辑

通过函数实现十进制转二进制

摘要: def func(n, first=True): if n == 0: if first: return '0b0' else: return '0b' return str(func(n//2, False))+str(n%2) print(func(0)) print(func(3)) prin 阅读全文

posted @ 2020-04-25 14:37 __director 阅读(470) 评论(0) 推荐(0) 编辑

统计重复字符串并排序

摘要: string = 'aovbzoasvaobvdoaobgvo;sogvosov;svgoas;shvbpe;;svoovohoaosobvboeaso' string_set = list(set(string)) print(string_set) conuts = list(map(strin 阅读全文

posted @ 2020-04-25 14:25 __director 阅读(137) 评论(0) 推荐(0) 编辑

time 模块

摘要: time.time() #获取当前时间戳 1587743489.9542704 time.localtime() #获取本地时间,年月日时分秒周,一年中第几天 time.struct_time(tm_year=2020, tm_mon=4, tm_mday=24, tm_hour=23, tm_mi 阅读全文

posted @ 2020-04-25 00:12 __director 阅读(108) 评论(0) 推荐(0) 编辑

导航