Making data transfer progress bar with Python builder

Source: Internet
Author: User

There are several data in the process

1 data that has been transferred received_size

2 File Size Tatol

A = received_size/tatol B = a*100 where A is the percentage of data transferred, and B is the progress that has been transferred, with a total progress of 100

Print now as soon as the implementation progress has been updated #

1 #_*_coding:utf-8_*_2 #Author:jaye He3 Import Time4 5 6 defshow_progress (total):7Received_size = 0#received file size8current_percent = 0#Receive Progress9          whileReceived_size <Total:Ten             ifInt ((received_size/total) *100) >current_percent: One                 Print('#', end="', flush=True) Acurrent_percent = Int ((received_size/total) *100) -Received_size =yield -  the  -Total = 100000#Total File Size -  - #start the generator progress +Progress =show_progress (total) - #Start boot must be started with. __NEXT__ () and cannot be used directly with Send + #otherwise appears typeerror:can ' t send non-none value to a just-started generator AProgress.__next__() at  -Received_size = 0#simulate the size of the received data -  - #Analog data transfer -  whileReceived_size <Total: -Time.sleep (0.3)#simulate the time spent on each transfer of data inReceived_size + = 1000#simulates the size of each transmitted data -     Try:#Handling Stopiteration Exceptions toProgress.send (Received_size)#send the latest received_size to progress +     exceptstopiteration as E: -         Print('100%')
# ############################################################################################### #100%      # Results Demo

Making data transfer progress bar with Python builder

Related Article

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.