#coding:utf-8 import cx_Oracle as oracle import os fp = open('E:\\PyWk\\nodepad_py\\db\\db.txt') a = fp.readlines() fp.close() a = [x.replace('\n', '') for x in a] db = oracle.connect('******', '******', '******:1521/***') cr = db.cursor() t = [] for i in a: temp = 'select count(1) from ac01 where aac002=\'' + i +'\'' cr.execute(temp) rs = cr.fetchall() print rs t += rs cr.close() db.close() #print '***********' #print t #print '*****1*****' t1 = [str(x[0]) + '\n' for x in t] #print t1 fp = open('E:\\PyWk\\nodepad_py\\db\\rs.txt', 'w') fp.writelines(t1) fp.close()