from qqwry import QQwry q = QQwry() q.load_file('qqwry_lastest.dat')
data = open('ip.txt') data1 = data.readlines() ipresult = open('jieguo.txt','w') for i in data1: result = q.lookup(i.strip()) city = result[0] typenet = result[1] ipresult.write(i.strip()+'\t' + city + '\t' + typenet + '\n') ipresult.close()