• 根据指定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()
  • 相关阅读:
    js根据ip地址获取城市地理位置
    vue-cli项目中使用mock结合axios-mock-adapter生成模拟数据
    将图片转canvas
    判断浏览器是否联网
    头尾固定中间高度自适应布局 css
    经典闭包
    多余文字转化为省略号css
    $.grep()
    node 图片转base64
    CentOS 7下安装Mysql 5.7
  • 原文地址:https://www.cnblogs.com/zyl-kx/p/11346816.html
Copyright © 2020-2023  润新知