zoukankan      html  css  js  c++  java
  • Python 文件拼接

    # -*- coding:utf-8 -*-
    import re
    import csv
    
    file = open('make_setup.cfg', 'w+')
    
    with open("tyb.csv", "r", encoding="GBK") as csvfile:
        # 读取csv文件,返回的是迭代类型
        read = csv.reader(csvfile)
        aa = list(read)
        file.write('[setup_basic]
    '
                   'zip=source/Stock.7z
    '
                   'xml=source/setup.xml
    '
                   'org_exe=setup.bin
    '
                   '[setup_skin]
    '
                   'IDR_BTN_BK_BIG            = "source/skin/Install_Btn_Start.png" 
    '
                   'IDR_UNCHECK               = "source/skin/CHECKBNBK.png"
    '
                   '
    ')
        for i in range(len(aa)):
            pattern = re.compile(r'd+')  # 正则表达式,获取数字
            sid = pattern.findall(aa[i][1])
            sid1 = ''.join(sid)  # list转换为str
            tid = pattern.findall(aa[i][2])
            tid1 = ''.join(tid)
            packageno = pattern.findall(aa[i][0])
            a = '[' + 'setup_target' + str(i + 1) + ']' + '
    ' + 'sid=' + sid1 + '.' + tid1 + '
    ' + 'packageno=' + 
                packageno[2] + '
    ' + 'target=targets/' + aa[i][0] + '
    '
            file.write(a + '
    ')
        file.close()
  • 相关阅读:
    处理数据
    Vue--Vue常用指令及操作
    Vue--Vue实例
    ES6--解构赋值
    ES6--入门
    前端模块化开发
    Node.js--入门
    HTML5--canvas与svg的使用
    input整理
    移动端开发入门
  • 原文地址:https://www.cnblogs.com/soloate/p/10455354.html
Copyright © 2011-2022 走看看