摘要: 当使用win32com时报错,不知道代码的含义,可以使用以下方法查询报错说明,方便定位错误 import win32api print(win32api.FormatMessage(-2147352565)) # 如上图中的错误代码,打印后中文描述为“无效索引。”,那就说明是你传入的索引是错误的 阅读全文
posted @ 2024-06-13 09:55 cnblogs用户 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 方法一(通用) 在前面 如果你的python是x32的,并且安装的是WPS,可以考虑使用三方库win32com来实现。 示例代码 import win32com.client as client source_file = r"C:\Users\xxx\Desktop\test!.xlsx" tar 阅读全文
posted @ 2024-06-13 09:43 cnblogs用户 阅读(16) 评论(0) 推荐(0) 编辑
摘要: Excel转csv可以使用pandas的to_excel、to_csv实现转换,但是当Excel文件较大时,pandas耗时会较多,可以考虑使用win32com实现 import win32com.client xl = win32com.client.Dispatch("Excel.Applica 阅读全文
posted @ 2024-05-29 10:05 cnblogs用户 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 前言 python读取Excel文件的库有pandas、openpyxl、xlrd等,但是各有优缺点,虽说openpyxl在指定read_only参数后读取大型文件的速度非常快,但是它只适用于xlsx类型文件,且有些银行系统下载的报表不手动打开进行保存它都无法完整读取一行数据。最终基本都会使用pan 阅读全文
posted @ 2024-05-24 14:58 cnblogs用户 阅读(70) 评论(0) 推荐(0) 编辑
摘要: 导包 import datetime from pathlib import Path import pytz from exchangelib import ( Configuration, Account, DELEGATE, Q, Credentials, HTMLBody, Message, 阅读全文
posted @ 2024-02-06 10:25 cnblogs用户 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 不使用logging模块,只是简单的输出某一个函数的异常信息 # coding:utf-8 import sys import pandas as pd def test(): try: pd.DataFrame('') except ValueError: error_msg = '执行异常![{ 阅读全文
posted @ 2023-12-27 10:54 cnblogs用户 阅读(34) 评论(0) 推荐(0) 编辑
摘要: html_doc = """ <html><head><title>The Dormouse's story</title></head> <body> <p class="title"><b>The Dormouse's story</b></p> <p class="story">Once up 阅读全文
posted @ 2023-12-06 16:48 cnblogs用户 阅读(37) 评论(0) 推荐(0) 编辑
摘要: 效果展示 原始文件 划线后文件 代码实现 # coding:utf-8 import os from win32com.client import Dispatch def get_string_index(substring, string): """ 获取同一字符串中的多个相同字符串的起始索引 阅读全文
posted @ 2023-12-05 14:37 cnblogs用户 阅读(219) 评论(0) 推荐(0) 编辑
摘要: 效果展示 原始文件 划线后文件 代码实现 # coding:utf-8 import os import fitz # PyMuPDF def pdf_underline_text(pdf_path, search_text, output_path=None): """ 在PDF文件中指定的文字下 阅读全文
posted @ 2023-12-05 14:35 cnblogs用户 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 方法一:xlwings import os.path import uuid from io import BytesIO from typing import Union import xlwings as xw from PIL import ImageGrab def excel_grab(e 阅读全文
posted @ 2023-12-04 13:29 cnblogs用户 阅读(1462) 评论(0) 推荐(1) 编辑
摘要: 本地yum源 上传centos镜像至linux系统 # 使用xftp工具上传 # scp上传 创建iso挂载目录 mkdir /mnt/yum-iso 挂载系统镜像 mount -o loop /opt/CentOS-7.xxxxx.iso /mnt/yum-iso/ 移走原有的yum源 cd /e 阅读全文
posted @ 2023-10-18 14:40 cnblogs用户 阅读(92) 评论(0) 推荐(0) 编辑
摘要: 参数说明 -F, –onefile | 打包一个单个文件,如果你的代码都写在一个.py文件的话,可以用这个,如果是多个.py文件就别用 -D, –onedir | 打包多个文件,在dist中生成很多依赖文件,适合以框架形式编写工具代码 -w, –windowed,–noconsole | 使用Win 阅读全文
posted @ 2023-09-21 09:21 cnblogs用户 阅读(195) 评论(0) 推荐(0) 编辑
摘要: ```python import re import os import email from email.header import decode_header from email.utils import parsedate_to_datetime def parse_eml(eml_fp, 阅读全文
posted @ 2023-09-01 09:22 cnblogs用户 阅读(1611) 评论(0) 推荐(0) 编辑
摘要: 数据准备 import pandas as pd product_info = { "订单号": [ "2951110000099262111", "2181910000909928191", "2194560000121355545", "1194560000121311126", "148316 阅读全文
posted @ 2023-08-07 09:43 cnblogs用户 阅读(88) 评论(0) 推荐(0) 编辑
摘要: # 数据准备 ```python import pandas as pd product_info = { "订单号": ["2951110000099262111", "2181910000909928191", "2194560000121355545", "119456000012131112 阅读全文
posted @ 2023-08-07 08:36 cnblogs用户 阅读(29) 评论(0) 推荐(0) 编辑