摘要: ```python import os from datetime import datetime import pytz from exchangelib import Credentials, Account, Configuration, DELEGATE, Q, FileAttachment 阅读全文
posted @ 2023-05-19 13:59 cnblogs用户 阅读(571) 评论(0) 推荐(0) 编辑
摘要: from pathlib import Path base_dir = Path('E:/测试目录A/测试目录B/测试文档.txt') 获取父级目录 parent = base_dir.parent print(parent) # E:\测试目录A\测试目录B parents = base_dir. 阅读全文
posted @ 2023-02-28 14:37 cnblogs用户 阅读(38) 评论(0) 推荐(0) 编辑
摘要: import datetime import calendar def get_quarter_date(quarter='current'): """ 获取当前季度或上一季度的起止日期 :param quarter: [current , last], default current :retur 阅读全文
posted @ 2022-12-14 13:52 cnblogs用户 阅读(598) 评论(0) 推荐(0) 编辑
摘要: 单元格拆分 def get_index(capital): """ 大写字母(Excel列头)转数字 :param capital: 'A' --> 0, 'AA' --> 26 :return: int """ number = 0 capital = capital.upper() for ch 阅读全文
posted @ 2022-08-03 09:49 cnblogs用户 阅读(2572) 评论(0) 推荐(0) 编辑
摘要: ### 纵向拼接 ```python from PIL import Image def image_splicing(pic01, pic02): """ 图片拼接 :param pic01: 图片1路径 :param pic02: 图片2路径 :return: 保存路径 """ with Ima 阅读全文
posted @ 2022-07-08 11:27 cnblogs用户 阅读(1272) 评论(0) 推荐(0) 编辑
摘要: 获取上月开始结束日期 方法一 import datetime def get_date_of_last_month(form="%Y-%m-%d"): """ 获取上月开始结束日期 :param form 返回值显示格式 :return: str,date tuple """ today = dat 阅读全文
posted @ 2022-05-17 16:54 cnblogs用户 阅读(3537) 评论(0) 推荐(0) 编辑
摘要: round 以下示例展示对于结构相同的两组数据(1.03575000和1.03425000)保留小数后4位,使用内置函数round方法的输出结果,并不是需要的结果 print(round(1.03575000, 4)) print(round(1.03425000, 4)) """ 1.0357 1 阅读全文
posted @ 2022-05-11 18:24 cnblogs用户 阅读(1065) 评论(0) 推荐(0) 编辑
摘要: 激活指定窗口 import win32gui import win32con def match_windows(win_title): """ 查找指定窗口 :param win_title: 窗口名称 :return: 句柄列表 """ def callback(hwnd, hwnds): if 阅读全文
posted @ 2022-04-22 11:29 cnblogs用户 阅读(7530) 评论(2) 推荐(0) 编辑
摘要: 只使用`reportlab`库好像没法在已经有内容的PDF页面中写入数据,只能生成一个空的PDF文件再写入。所以配合`pdfrw`库来实现的。具体见示例 ```python from reportlab.pdfgen.canvas import Canvas from pdfrw import Pd 阅读全文
posted @ 2022-03-11 15:02 cnblogs用户 阅读(902) 评论(0) 推荐(0) 编辑
摘要: ###字母转数字 def get_index(capital): """ 大写字母(Excel列头)转索引 :param capital: 'A' --> 0, 'AA' --> 26 :return: int """ number = 0 capital = capital.upper() for 阅读全文
posted @ 2021-09-03 11:01 cnblogs用户 阅读(389) 评论(0) 推荐(0) 编辑
摘要: ###使用openpyxl实现 只支持xlsx文件,不支持xls import openpyxl def read_cell(io, sheet, cell='A2'): """ 读取单元格 :param io: Excel文件路径 :param sheet: 读取哪一张表,str, int eg: 阅读全文
posted @ 2021-08-31 11:32 cnblogs用户 阅读(3342) 评论(0) 推荐(0) 编辑
摘要: import datetime def get_date_of_last_week(form='%Y-%m-%d'): """ 获取上周开始结束日期 :param form: 日期格式 :return: str,date tuple """ today = datetime.date.today() 阅读全文
posted @ 2021-08-19 21:00 cnblogs用户 阅读(555) 评论(0) 推荐(0) 编辑
摘要: 注:chinese_calander库需要每年手动更新一次 import datetime import chinese_calendar def get_holidays(year=None, include_weekends=True): """ 获取某一年的所有节假日,默认当年 :param 阅读全文
posted @ 2021-08-19 20:53 cnblogs用户 阅读(2295) 评论(0) 推荐(0) 编辑
摘要: 通过发票左上角的二维码信息,获取发票的关键信息,只需将图片格式的电子发票或扫描后的发票图片传入即可. 测试结果如下: * 增值税电子普通发票:`{'发票代码': '031xxxxxx311', '发票号码': '74xxxx17', '不含税金额': '13665.98', '开票日期': '202 阅读全文
posted @ 2021-07-09 14:33 cnblogs用户 阅读(1606) 评论(0) 推荐(0) 编辑
摘要: 下面示例代码,是将横向纸张旋转为纵向(根据纸张大小判断纸张方向) 方法一:使用`PyPDF2`库 ```python from PyPDF2 import PdfFileWriter, PdfFileReader def page_rotation(old_file, new_file): """ 阅读全文
posted @ 2021-07-01 17:11 cnblogs用户 阅读(1472) 评论(1) 推荐(0) 编辑