簡體   English   中英

How to suppress or prevent http header response returned from Box python API from printing in the cell output in Jupyter notebook

[英]How to suppress or prevent http header response returned from Box python API from printing in the cell output in Jupyter notebook

我是使用 API 的新手。 我在 Jupyter Notebook 中運行一個迭代器,它調用 Box.com API 獲取一些數據( .docx.pdf文件)。 主 function 單元格在迭代時為每個目錄打印大量 http header 響應。 當我迭代大約 9000 個文件時,這種情況會逐漸增加,使筆記本變得超級重(超過 100 Mb)。 此時,即使我使用 16Gb RAM,筆記本電腦也會變得無響應。
有沒有辦法抑制那些 header 響應,防止它們在單元格 output 中打印,或者替代方法?
我已經嘗試了 API 調用和%%capture框末尾的分號( ; )。 我不確定我在這里做錯了什么。 我需要 output 來訓練 word2vec model 並且我已經構建了整個數據處理管道。 來自輸出單元的樣本片段

我想到了。 您可以使用logging中的日志記錄來控制筆記本單元格中的日志/標題輸出級別。 唯一要注意的(我錯過了)是您必須在要為其修剪 output 的特定單元格的頂部添加日志記錄語句。 它的 scope 僅限於單元格,而不是整個 Jupyter Notebook。

注意:任何 Python print()語句都不受此影響。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM