python新建文件并全文设置文本格式

import os
import shutil
import numpy as np
from tkinter import filedialog, Tk
from os import getcwd
from re import findall

import xlwt

def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    f = xlwt.Workbook(encoding='utf-8',style_compression=0)  # 创建workbook,其实是execl
    sheet1 = f.add_sheet('Sheet1', cell_overwrite_ok=True)
    style1 = xlwt.XFStyle()  # 设置单元格格式为文本
    style1.num_format_str = '@'
    for i in range(0, 110):
        for j in range(0, 30):
            sheet1.write(i, j, style=style1)
    f.save(r'E:\老人卡\XXXXX操作员.xlsx')
    print(f'Hi, {name}')

if __name__ == '__main__':
    print_hi('Linlili~~~~~')

 

posted @ 2022-04-22 10:18  dafengchui  阅读(147)  评论(0)    收藏  举报