我有一个类ProcessingFlush,它是从前面的post派生的。我编写这个类是为了打印一系列的点(由索引给出),以测试我的软件是否在数据大小未知的情况下处理数据。在
class ProcessingFlush(object):
def __init__(self, index):
if index > 70:
raise ValueError("Index not valid")
self.index = index
def update(self, n):
self._n = n
self._display()
def finish(self):
sys.stdout.flush()
def start(self):
sys.stdout.write("Processing")
def _display(self):
sys.stdout.write("Processing %s%s\r" % ((n % index)* ".", (index - 1 - (n % index))* " "))
sys.stdout.flush()
pr = ProcessingFlush(5)
pr.start()
for n in xrange(5000):
pr.update(n)
pr.finish()
这个类的限制是当处理非常快时“处理”的闪烁效果。我试图发展这个想法来解决这个问题,但没有结果。我希望创建一个模块启动
^{pr2}$只打印加工。在
def _display(self):
sys.stdout.write("%s%s%s\r" % ((" " * 10),(self._n % self.index)* ".", (self.index - 1 - (self._n % self.index))* " "))
sys.stdout.flush()
只显示打印处理点。在
相关问题 更多 >
编程相关推荐