随笔分类 -  python常用笔记 / 办公自动化

摘要:import PyPDF2# 打开PDF文件with open("example.pdf", "rb") as pdf_file: # 创建PDF文件对象 pdf_reader = PyPDF2.PdfFileReader(pdf_file) # 获取PDF文件中第一页 page = pdf_rea 阅读全文
posted @ 2023-04-22 16:32 code星 阅读(331) 评论(0) 推荐(0) 编辑
摘要:import pandas as pd# 创建多级索引index = pd.MultiIndex.from_arrays([['A', 'A', 'A', 'B', 'B', 'B'], [1, 2, 3, 1, 2, 3]], names=['group', 'number'])# 创建DataF 阅读全文
posted @ 2023-04-22 14:39 code星 阅读(29) 评论(0) 推荐(0) 编辑
摘要:import pandas as pd# 读取CSV文件df = pd.read_csv('data.csv')# 读取Excel文件df = pd.read_excel('data.xlsx')# 读取SQL数据import sqlite3conn = sqlite3.connect('data. 阅读全文
posted @ 2023-04-22 14:37 code星 阅读(19) 评论(0) 推荐(0) 编辑
摘要:from pptx import Presentation# 创建一个新PPT文档prs = Presentation()# 添加幻灯片slide = prs.slides.add_slide(prs.slide_layouts[0])# 保存PPT文档prs.save('example.pptx' 阅读全文
posted @ 2023-04-22 14:32 code星 阅读(769) 评论(0) 推荐(0) 编辑
摘要:from docx import Documentfrom docx.enum.section import WD_SECTION# 创建一个新文档doc = Document()# 添加页眉header = doc.sections[0].headerheader.add_paragraph('H 阅读全文
posted @ 2023-04-22 14:26 code星 阅读(384) 评论(0) 推荐(0) 编辑
摘要:from docx import Document# 创建一个新文档doc = Document()# 添加段落para = doc.add_paragraph('Hello World!') from docx.enum.style import WD_STYLE_TYPEfrom docx.en 阅读全文
posted @ 2023-04-22 14:23 code星 阅读(89) 评论(0) 推荐(0) 编辑
摘要:from openpyxl.styles import Font, Alignment, PatternFill# 设置字体样式font = Font(name='Calibri', size=12, bold=True, italic=False, underline='single')ws['A 阅读全文
posted @ 2023-04-22 14:20 code星 阅读(87) 评论(0) 推荐(0) 编辑
摘要:from openpyxl import load_workbook# 打开一个已存在的Excel文件wb = load_workbook(filename='example.xlsx')# 创建一个新的Excel文件wb = Workbook() # 选择第一个工作表ws = wb.active# 阅读全文
posted @ 2023-04-22 14:18 code星 阅读(66) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示