huhahapz 发表于 2017-5-2 07:32:16

记录一次用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 MySQLdb
conn = 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
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()
 
页: [1]
查看完整版本: 记录一次用python 查询会员