【发布时间】:2019-12-09 20:11:03
【问题描述】:
从此python3代码:
#!/usr/bin/env python3
from progress.bar import Bar
bar = Bar("Percent of this year : ", max=100)
for i in range(int(50)):
bar.next()
bar.finish()
我在控制台中打印了这个输出:
Percent of this year : |################ | 50/100
输出正是我需要的,但我不想将它用作控制台中的打印输出。
我需要将它保存在要写入文件的变量中。
我想要这个结果:
print(myvar)
Percent of this year : |################ | 50/100
【问题讨论】:
-
为什么需要将其存储在变量中?您是否考虑过将输出重定向到“python 文件名> output.log”之类的日志文件。 ?
标签: python python-3.x progress-bar