读书人

记要一次用python 查询会员

发布时间: 2012-08-29 08:40:14 作者: rapoo

记录一次用python 查询会员

data:

tes120@qq.com
safdsf@foxmail.com

tes120@qq.com
safdsf@foxmail.com

tes120@qq.com
safdsf@foxmail.com

tes120@qq.com
safdsf@foxmail.com

?

?

python:

#!/bin/py# -*- coding: utf-8 -*- import MySQLdbconn = MySQLdb.connect(host='localhost',user='1',passwd='1',charset='utf8')cursor = conn.cursor()cursor.execute('use zcwdb');list = []f = open("data.txt","r")for read in f.readlines():    if(read.find("\n")>0):        read=read[0:len(read)-1]    list.append(read);#print list#while(w=print f.readline()):#   print w; sql = "select id from auth_user where email ='%s'";for l in list:  cursor.execute(sql%l)  results = cursor.fetchall()  print l+"\t",results#获取数据#cursor.execute('select * from test')#results = cursor.fetchall()  #for r in results#     print r#conn.close()
?

?

读书人网 >perl python

热点推荐