上一页 1 ··· 82 83 84 85 86 87 88 89 90 ··· 100 下一页
摘要: 执行格式: ./set_bridge.sh -i 192.168.4.72 -g 192.168.4.1 结果: [root@localhost ~]# ifconfigbr0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192 阅读全文
posted @ 2017-09-19 08:57 Oops!# 阅读(1203) 评论(0) 推荐(0) 编辑
摘要: 使用正则表达式收集主机信息 #!/usr/bin/env python from subprocess import Popen, PIPE import re def getIfconfig(): p = Popen(['ifconfig'], stdout=PIPE) data = p.stdo 阅读全文
posted @ 2017-09-14 16:48 Oops!# 阅读(231) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python from subprocess import Popen, PIPE def getIfconfig(): p = Popen(['ifconfig'], stdout=PIPE) data = p.stdout.read() return data de 阅读全文
posted @ 2017-09-14 16:24 Oops!# 阅读(247) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python from subprocess import Popen, PIPE def getIfconfig(): p = Popen(['ifconfig'], stdout=PIPE) data = p.stdout.read().split('\n\n') 阅读全文
posted @ 2017-09-14 16:09 Oops!# 阅读(225) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python from subprocess import Popen, PIPE p = Popen(['dmidecode'], stdout=PIPE) data = p.stdout lines = [] dmi = {} a = True while a: l 阅读全文
posted @ 2017-09-14 15:46 Oops!# 阅读(423) 评论(0) 推荐(0) 编辑
摘要: 按字典值排序 按照字典value排序,类似sort -k 命令 import operator x= {1:2,3:4,4:3,2:1,0:0} sorted_x = sorted(x.iteritems(), key=operator.itemgetter(1)) In [38]: sorted_ 阅读全文
posted @ 2017-09-14 14:40 Oops!# 阅读(184) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python import sys import hashlib def md5sum(f): m = hashlib.md5() with open(f) as fd: while True: data = fd.read(4096) if data: m.updat 阅读全文
posted @ 2017-09-14 14:17 Oops!# 阅读(174) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/python import sys import os try: fn = sys.argv[1] except IndexError: print "please follow a argument at %s" % __file__ sys.exit() if not os 阅读全文
posted @ 2017-09-14 11:48 Oops!# 阅读(560) 评论(0) 推荐(0) 编辑
摘要: vim wc.py #!/usr/bin/python def wordCount(s): chars = len(s) words = len(s.split()) lines = s.count('\n') print lines, words, chars if __name__ == '__ 阅读全文
posted @ 2017-09-14 11:11 Oops!# 阅读(250) 评论(0) 推荐(0) 编辑
摘要: Python 函数 lambda 匿名函数 -lambda 函数是一种快速定义单行的最小函数,可以用在任何需要函数的地方。 def fun(x,y): return x*y fun(2,3) r=lambda x,y:x*y r(2,3) In [10]: def fun(x,y): ....: r 阅读全文
posted @ 2017-09-14 09:51 Oops!# 阅读(211) 评论(0) 推荐(0) 编辑
上一页 1 ··· 82 83 84 85 86 87 88 89 90 ··· 100 下一页