[英]How to change text color from a python module (tqdm module) output ? (so not python text editor output)
I am using the dark theme in Google Colab which automatically transforms text color from output to white.我在 Google Colab 中使用深色主题,它会自动将文本颜色从 output 转换为白色。 However, now I am using the progressbar from TQDM module and I get text that is dark colored which is problematic in the dark theme.
但是,现在我正在使用 TQDM 模块中的进度条,我得到的文本是深色的,这在深色主题中是有问题的。 I was thinking of Colorama but it only changes text color for the text edit (I think?).
我在考虑 Colorama,但它只会更改文本编辑的文本颜色(我认为?)。 Here is my code:
这是我的代码:
import yahoo_fin
from yahoo_fin.stock_info import get_data
bar = trange(72)
bar.write("Downloading data...")
for i,stocks in zip(bar,filtered_list):
df[stocks]= get_data(stocks,stockstart,stockend)['adjclose'].dropna()
bar.write("Completed!")
I was having this issue in Colab, and running the following code in a cell solved it for me:我在 Colab 中遇到了这个问题,在单元格中运行以下代码为我解决了这个问题:
# Set the tqdm text color to white.
from IPython.display import HTML, display
def set_css_in_cell_output():
display(HTML('''
<style>
.jupyter-widgets {color: #d5d5d5 !important;}
.widget-label {color: #d5d5d5 !important;}
</style>
'''))
get_ipython().events.register('pre_run_cell', set_css_in_cell_output)
(Inspired by this StackOverflow answer) (受此StackOverflow 答案的启发)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.