首页 > 代码库 > normal.1

normal.1

11

# coding:utf-8def maxnum(ipstr):	ipstr = ipstr.split(‘	‘)[1]	return ipstrdef minnum(ipstr):	ipstr =ipstr.split(‘.‘)[3]	ipstr = ipstr.split(‘	‘)[0]	return ipstrdef ip_before(ipstr):	ipstr_be =ipstr.split(‘.‘)[0]+‘.‘+ipstr.split(‘.‘)[1]+‘.‘+ipstr.split(‘.‘)[2]+‘.‘	return ipstr_bedef main():	f = open(‘iptest.txt‘,‘r‘)	for i in f.readlines():		i = i.strip()		if minnum(i)==‘0‘:			a=1		else:			a=minnum(i)		for j in range(int(a),int(maxnum(i))+1,1):			ip =ip_before(i)+str(j)			f1 = open(‘ipok.txt‘,‘a‘)			print >>f1,ip			f1.close()	print ‘over‘if __name__ == ‘__main__‘:	main()

  文件读取:

eg.

192.168.1.1   100

192.168.3.200 255

normal.1