本文整理匯總了Python中book.Book.read_book方法的典型用法代碼示例。如果您正苦於以下問題:Python Book.read_book方法的具體用法?Python Book.read_book怎麽用?Python Book.read_book使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類book.Book
的用法示例。
在下文中一共展示了Book.read_book方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_read_book
# 需要導入模塊: from book import Book [as 別名]
# 或者: from book.Book import read_book [as 別名]
def test_read_book():
book = Book('test/test_text_file.txt')
book.read_book()
chapters = book.get_chapters
assert len(chapters) == 2
assert chapters[0].get('title') == 'Chapter 1'
sentences = chapters[0].get('sentences')
assert len(sentences) == 4
示例2: parse_all_books
# 需要導入模塊: from book import Book [as 別名]
# 或者: from book.Book import read_book [as 別名]
def parse_all_books():
for file in glob.glob("{}/*.txt".format(book_dir)):
print("Parsing... {}".format(file))
book = Book(file)
book.read_book()
book.count_distinct_words()
print(book)
all_books.append(book)