修饰器,增加缓存的意义[root@localhost /]# [root@localhost /]# cat zlg.py #!/bin/pythondef a(n,cache=None): if cache is None: cache={} if n in cache: return cache[n] ...【阅读全文】
[root@localhost /]# [root@localhost /]# cat zlg.py #!/bin/pythonfrom random import randintimport timemylist=[1,2,3,4]mylist.reverse()for x in mylist: print xmytuple=(1,2,3,4)for y in range(len(mytuple)-1,-1,-1): print mytuple[y]mystr='hello you are a b...【阅读全文】
[root@localhost /]# [root@localhost /]# cat ./for.py #!/bin/pythonfrom random import randintfrom itertools import chaina=[randint(10,100) for _ in range(20)]b=[randint(10,100) for _ in range(20)]c=[randint(10,100) for _ in range(20)]for n,m,v in zip(a,b,c): print n+m+vcou...【阅读全文】
[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 /]# ...【阅读全文】