To be a better coder
发布时间:2019-02-26 10:53:31
[root@localhost /]# [root@localhost /]# cat split.py #!/bin/pythonimport res='aa,bb:cc;dd/tee<ff>gg'def mysplit(s,symbol): t=[s] for num in symbol: res=[] map(lambda x:res.extend(x..........【阅读全文】
发布时间:2019-02-25 17:18:32
[root@localhost /]# [root@localhost /]# cat strduiqi.py #!/bin/pythonimport os, statli=os.listdir('/software/script/shell')st=[n for n in li if n.endswith(('.sh','.py'))]for nm in st: os.chmod(nm,os.stat(nm).st_mode | stat.S_IXGRP)[root@localhost /]# [root@localhost /]# .........【阅读全文】
发布时间:2019-02-25 16:57:05
[root@localhost /]# cat strduiqi.py #!/bin/pythonimport relog=open('/var/log/pacman.log').read()print re.sub('(\d{4})-(\d{2})-(\d{2})',r'\2/\3/\1',log)[root@localhost /]# 捕获组命名[root@localhost /]# cat strduiqi.py #!/bin/pythonimport relog=open('/var/log/pacman.log').read()print re.sub.........【阅读全文】
发布时间:2019-02-25 16:39:44
[root@localhost /]# cat strduiqi.py #!/bin/pythonmydict={'name':'zhuliguo','age':29,'student':'student'}length=max(map(len,mydict.keys()))for n in mydict: print(n.ljust(length),':',mydict[n])[root@localhost /]# ......【阅读全文】