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