Python implements the progress bar in the terminal

Source: Internet
Author: User

Tag:python    progress bar     terminal    

# -*- coding:utf-8 -*- # copyright: lustralisk# author: test#  Date: 2015-11-08 import sys, time class progressbar:    def  __init__ (SELF, COUNT = 0, TOTAL = 0, WIDTH = 50):         self.count = count         self.total = total        self.width =  width    def move (self):         Self.count += 1    def log (self):         sys.stdout.write ('   '  *  (self.width + 9)  +  ' \ R ')          sys.stdout.flush ()         progress  = self.width * self.couNt / self.total        sys.stdout.write (' {0:3}/{1:3}:  ' . Format (self.count, self.total))         sys.stdout.write (' # '  * progress +  '-'  *  (self.width - progress)  +  ' \ R ')          if progress == self.width:             sys.stdout.write (' \ n ')          sys.stdout.flush ()  bar = progressbar (total = 100) for i in  Range:     bar.move ()     bar.log ()      Time.sleep (1)


Python implements the progress bar in the terminal

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.