我需要一个epub的Python文本解决方案

2024-10-03 11:13:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要一个epub发短信

from epub_conversion.utils import open_book, convert_epub_to_lines

f = open("demofile.txt", "a")
book = open_book("razvansividra.epub")
lines = convert_epub_to_lines(book)

我用这个,但如果我用print(行),它只打印一行。图书馆有6年的历史了。你们知道好办法吗?在


Tags: tofromimporttxtconvert图书馆utilsopen
2条回答

关于https://github.com/aerkalov/ebooklib

EbookLib is a Python library for managing EPUB2/EPUB3 and Kindle files. It's capable of reading and writing EPUB files programmatically (Kindle support is under development).

The API is designed to be as simple as possible, while at the same time making complex things possible too. It has support for covers, table of contents, spine, guide, metadata and etc.

import ebooklib
from ebooklib import epub

book = epub.read_epub('test.epub')

for doc in book.get_items_of_type(ebooklib.ITEM_DOCUMENT):
    print doc

convert_epub_to_lines返回迭代器to lines,需要逐个迭代才能得到。在

相反,您可以使用“convert”获取所有行,请参见库文档中的:

https://pypi.org/project/epub-conversion/

相关问题 更多 >