當前位置: 首頁>>代碼示例>>Python>>正文


Python Book.to_tsv方法代碼示例

本文整理匯總了Python中book.Book.to_tsv方法的典型用法代碼示例。如果您正苦於以下問題:Python Book.to_tsv方法的具體用法?Python Book.to_tsv怎麽用?Python Book.to_tsv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在book.Book的用法示例。


在下文中一共展示了Book.to_tsv方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: open

# 需要導入模塊: from book import Book [as 別名]
# 或者: from book.Book import to_tsv [as 別名]
    series_page_html = r.read()
    with open(series_page_file, 'w') as f:
      f.write(series_page_html)
    time.sleep(1)

  # get links for every book in the series
  book_links = parse_book_links(series.href, series_page_html)
  logging.info('Found %d books' % len(book_links))
  for book_link in book_links:
    # get and download the book html_line_to_series
    if book_link.title is None:
      continue
    logging.info('Examining book %s from %s' % (book_link.title, book_link.href))
    book_file = 'data/html/%s_%s.html' % (clean_name(series.name), clean_name(book_link.title))
    if os.path.exists(book_file):
      logging.info('Reading book data from cached html file')
      with open(book_file) as f:
        book_html = f.read()
    else:
      logging.info('Reading book data from the web')
      r = br.open(book_link.href)
      book_html = r.read()
      with open(book_file, 'w') as f:
        f.write(book_html)
      time.sleep(1)

    book = Book(series.name, book_link.title, book_link.href, book_html)
    with open(output_file, 'a') as f:
      f.write(book.to_tsv())
      f.write("\n")
開發者ID:lotze,項目名稱:romance_names,代碼行數:32,代碼來源:download_data.py


注:本文中的book.Book.to_tsv方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。