日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

python批量生成excel測試數據

系統 2059 0

沒啥說的,直接上代碼。。。

            
              #!/usr/bin/env python3
# -*- coding:utf-8 -*- 


import xlwt
import time
import random

book = xlwt.Workbook(encoding='utf-8')
sheet = book.add_sheet('sheet1', cell_overwrite_ok=True)
row_col_list = [9, 10]

def set_title():
    title_kwgs = {
        "colnum1": "colnum1_name", "colnum2": "colnum2_name", "colnum3": "colnum3_name",
        "colnum4": "colnum4_name", "colnum5": "colnum5_name",
        "colnum6": "colnum6_name", "colnum7": "colnum7_name", "colnum8": "colnum8_name",
        "colnum9": "colnum9_name", "colnum10": "colnum10_name"
    }
    for i in range(1):
        for j in range(row_col_list[1]):
            sheet.write(i, j, title_kwgs["colnum%s" % str(j + 1)])

def excel_data_generator():
    col_kwgs = {
        "colnum1":"colnum1_value", "colnum2":"colnum2_value", "colnum3":"colnum3_value",
        "colnum4":"colnum4_value", "colnum5":"colnum5_value",
        "colnum6":"colnum6_value", "colnum7":"colnum7_value", "colnum8":"colnum8_value",
        "colnum9":"colnum8_value", "colnum10":"colnum10_value"
    }

   

 colnum5_begin = int(str(random.Random.random(random.Random())).replace('0.', ''))
    for i in range(1, row_col_list[0] + 1):
        for j in range(row_col_list[1]):
            if j == 4:
                sheet.write(i, j, str(colnum5_begin))
                colnum5_begin += 1
            else:
                sheet.write(i, j, col_kwgs["colnum%s" % str(j + 1)])
    book.save("D:\\testdata\\haha\\test%s.xls" % str(time.time()).replace('.', ''))
    # time.sleep(1)
    # print('function executed!')


if __name__ == '__main__':
    for i in range(10):
        set_title()
        excel_data_generator()

            
          

更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦?。。?/p>

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 汝阳县| 垣曲县| 广平县| 嘉兴市| 北海市| 西丰县| 昆明市| 贡嘎县| 白银市| 宾川县| 陇南市| 塔河县| 新乐市| 清镇市| 烟台市| 油尖旺区| 南木林县| 大化| 同江市| 安顺市| 筠连县| 报价| 喜德县| 永清县| 青川县| 五指山市| 瑞金市| 平定县| 太保市| 浠水县| 石林| 姜堰市| 宜春市| 胶南市| 丽江市| 榆中县| 泸水县| 天等县| 金华市| 吉安县| 图片|