To be a better coder
发布时间:2019-01-24 13:09:48
[root@localhost /]# [root@localhost /]# cat zlg.py #!/bin/pythonfrom functools import reducea=[1,2,3,4,5,6,7,8,9]b=[2,3,4,5,6,7,8,9,1]r=map(lambda x,y:x+y,a,b)print list(r)x=3y=4print x if x>y else yp=reduce(lambda x,y:x+y,a)print p[root@localhost /]# [root@localhost /]# .........【阅读全文】
发布时间:2019-01-23 17:20:57
帮助函数:>>> help(str.join)>>> help(str)>>> [root@localhost /]# cat zifuchuan.py #!/bin/pythona='aaaaaaaaaaaaa'b='bbbbbbbbbbbb'c=a+bprint cd=['ddddddd','eeeeeeee','fffffffff']g=':'.join(d)h=''.join(d)print g,ho=['aaaaa',12,'23']print ''.join(str(x) for x in o)[root@localhost /]# .........【阅读全文】
发布时间:2019-01-22 12:55:46
netstat -r| sed '1,3d' | awk '{print $8}' | sort -k2n | awk '!i[$1]++'......【阅读全文】
发布时间:2019-01-22 10:43:36
[root@localhost /]# cat zifuchuan.py #!/bin/pythonimport res=' ---asdegsd:34fr++++ 'print(s.strip())print(s.lstrip())print(s.rstrip())print(s[:11]+s[12:])print(s.replace('-','h'))print(s.translate(None,'a'))print(re.sub('a','',s))[root@localhost /]# ......【阅读全文】
发布时间:2019-01-21 13:17:07
[root@localhost /]# cat key.py #!/bin/pythonfrom random import *import refrom collections import Countera=[randint(1,15) for _ in range(20)]b=dict.fromkeys(a,0)for i in b: b[i]+=1e=[(k,v) for k,v in b.items()]print(sorted(e))c=Counter(a)d=c.most_common(3)print aprint .........【阅读全文】