文章 2022-09-04 来自:开发者社区

Python编程:读取pdf、pptx、docx、xlsx文件的页数

pdf安装工具pip install pdfplumber代码示例import pdfplumber from pdfminer.pdfparser import PDFSyntaxError def get_pdf_page(pdf_path): try: f = pdfplumber.open(pdf_path) page = len(f.pages)...

文章 2022-09-04 来自:开发者社区

Python编程:pypdf2和pdfplumber获取pdf文件的页数

pypdf2安装pip install pypdf2 代码实例from PyPDF2 import PdfFileReader filename = "test.pdf" reader = PdfFileReader(filename) # 不解密可能会报错:PyPDF2.utils.PdfReadError: File has not been decrypted if reader.isEn....

文章 2022-09-04 来自:开发者社区

Python编程:tempfile创建临时文件

tempfile需要的时候创建零时文件,关闭之后就被删除了import tempfile import os # 创建文件 file = tempfile.TemporaryFile(mode="w+") print(file.name) # 4 print(os.path.exists(file.name)) # True # 写入、读取操作 file.write("hello world")....

文章 2022-09-02 来自:开发者社区

Python编程:watchdog模块监控系统文件变化

详情参考官方文档:https://github.com/gorakhargosh/watchdog监控文件示例详情参考官方文档: https://github.com/gorakhargosh/watchdog 监控文件示例 import time from watchdog.observers import Observer from watchdog.events import FileSy....

文章 2022-08-29 来自:开发者社区

Python编程:pyinstaller打包成exe可执行文件

安装pyinstaller方式一:pip install pywin32   # 不安装可能会报错pip install PyInstaller方式二:下载zip文件安装官网:http://www.pyinstaller.org/或者:https://pypi.python.org/pypi/PyInstaller/3.3.1方式三:下载whl文件安装,地址:https://www.l....

文章 2022-08-28 来自:开发者社区

Python编程:读写excel文件

写入xlsx文件import xlsxwriter # pip install XlsxWriter # 新建工作薄 workbook = xlsxwriter.Workbook('hello.xlsx') # 新建工作表 worksheet = workbook.add_worksheet() # 写入 worksheet.write('A1', 'Hello world') # 关闭工作...

文章 2022-08-27 来自:开发者社区

Python编程:yaml文件读写

yaml 库安装:http://pyyaml.org/读取import yaml f = open("data.yaml", "r") data = yaml.load(f) f.close() print(data) """ [ { 'name': 'PyYAML', 'status': 4, }, { 'name':...

文章 2022-08-27 来自:开发者社区

Python编程:xlm文件读写

xml文件增删改查先引入解析xml文档的模块import xml.etree.ElementTree as ET tree = ET.parse("data.xml") # 解析文档 root = tree.getroot() # 获取根节点 print(root) print(root.tag)读取# 遍历文档 for child in root: print(child.tag,...

文章 2022-08-27 来自:开发者社区

Python编程:shutil模块-操作目录及文件

操作目录及文件import shutil f1 = open("file.txt", "r", encoding="utf-8") f2 = open("file_new.txt", "w", encoding="utf-8") shutil.copyfileobj(f1, f2) # 通过文件对象拷贝文件内容 shutil.copyfile("file.txt", "file_new.txt.....

文章 2022-08-27 来自:开发者社区

Python编程:获取ftp目录下文件夹和文件

原文标题《python ftplib.FTP 获取当前路径下所有目录》python内置库ftplib中,FTP 模块里有一个dir函数,可以打印出当前路径下所有文件,但是这个函数没有返回值,只是打印出来。还有一个nlst函数,可以返回一个文件名的列表,但是只有文件名,没有详细信息,无法判断是否是目录。目前我只有两个笨办法,一个继承FTP类,自己实现一个getSubdir()方法,可以直接copy....

本页面内关键词为智能算法引擎基于机器学习所生成,如有任何问题,可在页面下方点击"联系我们"与我们沟通。

产品推荐

Python学习站

Python学习资料大全,包含Python编程学习、实战案例分享、开发者必知词条等内容。

+关注
相关镜像
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等

登录插画

登录以查看您的控制台资源

管理云资源
状态一览
快捷访问