今天同事需要有一个将excel 里面数据随机分成特定的几个组,并将每组数据分别生成excel
正好刚接触python,用python写了个小工具,打包成exe 很方便
#!/usr/bin/env python3
# encoding:utf-8
'''
@author: yingk
@file: excel.py
'''
import configparser
import xlrd
import xlwt
import os
from random import shuffle
def mkdir(path):
# 判断路径是否存在
# 存在 True
# 不存在 False
isExists = os.path.exists(path)
# 判断结果
if not isExists:
# 如果不存在则创建目录
# 创建目录操作函数
os.makedirs(path)
#os.path.realpath:获取当前执行脚本的绝对路径。
#os.path.split:如果给出的是一个目录和文件名,则输出路径和文件名
proDir = os.path.split(os.path.realpath(__file__))[0]
configPath = os.path.join(proDir, "config.ini")
conf = configparser.ConfigParser()
conf.read(configPath