• 根据指定id获取需要的正则内容


    import pymysql
    import re
    # import wenjianduqu
    def getResult(x,y):
    sql=cursor.execute("select regular from regular where regular_id=%d"%x)
    regular=cursor.fetchmany(sql)#获取查询结果
    Regular=eval(regular[0][0])
    regular_result=re.findall(Regular,f)
    sql=cursor.execute('insert into regular_result (regular_result,regular_id,file_id) values("%s","%d","%d")'%(regular_result,x,y))
    return sql

    conn = pymysql.connect(
    host='localhost',
    port=3306,
    user='root',
    passwd='123456',
    db='zch',
    charset='utf8',
    )
    cursor = conn.cursor()
    sql1=cursor.execute("select file_id from file")
    info=cursor.fetchmany(sql1)#获取查询结果
    #遍历id获得id对应的文件地址,取出并在本机搜索读取
    for i in info:
    sql = cursor.execute('select file_category_id,file_name from file where file_id=%d'%i)
    info = cursor.fetchmany(sql)
    address = cursor.execute('select file_address from file_category where file_category_id=%d'%info[0][0])
    file_address=cursor.fetchmany(address)
    if file_address[0][0] is None :
    print("当前文件已经全部遍历完")
    break
    else:
    file=file_address[0][0] +"\"+ info[0][1]
    f = open(file, "r",encoding = 'utf-8')
    f=f.read()
    f = open(file, "r",encoding = 'utf-8')
    f=f.read()
    if info[0][0] == 1:
    regular_id = (1,2,3,4)
    for j in regular_id:
    getResult(j,i[0])
    else:
    print('工作结束')

    cursor.close()
    conn.commit()#数据提交
    conn.close()
  • 相关阅读:
    2thweek.training.c。链表典型题
    队列—summer training B.
    栈—summertraining#2.A题
    周题:UVa10736题。Foreign Exchange
    UVA_11877.第三次比赛C题:The Coco Cola
    uva10465 Homer Simpson(水题)
    uva348 Optimal Array Multiplication Sequence(DP)
    uva116 Unidirectional TSP(DP)
    uva 607 Scheduling Lectures(DP)
    uva11598 Optimal Segments(DP 求方案)
  • 原文地址:https://www.cnblogs.com/zyl-kx/p/11346816.html
Copyright © 2020-2023  润新知