标签:
import socket,struct,sys,getopt,string def doAnalysis(ifile, ofile): infile = open(ifile, ‘r‘) onfile = open(ofile, ‘w‘) for line in infile.readlines(): info = line.split(‘\t‘) if len(info) >= 2: info[1] = socket.inet_ntoa(struct.pack(‘I‘, socket.htonl(string.atoi(info[1])))) onfile.write("%s\t%s\n"%(info[0], info[1])) infile.close() onfile.close() if __name__ == ‘__main__‘: opts, args = getopt.getopt(sys.argv[1:], "i:o:") infile = "" ofile = "" for op, value in opts: if op == "-i": infile = value if op == "-o": ofile = value if infile == "" or ofile == "": print ‘input infile and ofile !!!!!‘ sys.exit() else: doAnalysis(infile, ofile)
标签:
原文地址:http://my.oschina.net/u/659405/blog/511070