标签:mysqldb oca read dal mysqld lin 导入 open for
#导入相关模块
import MySQLdb
import os
import re
#建立和mysql数据库的连接
conn = MySQLdb.connect(host=‘localhost‘,user=‘root‘,passwd=‘123lqh‘)
conn.select_db(‘slowquery‘)
curs = conn.cursor()
file=open("new2.txt")
x=()
j=()
for line in file.xreadlines():
if ‘Count :‘ in line:
m=re.findall(r":(.+)",line)
print m
if ‘Time :‘ in line:
n=re.findall(r":(.+)",line)
print n
for x in m :
for j in n:
print x+j
~
标签:mysqldb oca read dal mysqld lin 导入 open for
原文地址:http://www.cnblogs.com/linqiuhua/p/7464735.html