Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the python text progress bar

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "how to realize the python text progress bar". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1, at the beginning (which may be very low) import timescale=10print ("- execution start -") for i in range (scale+1): a starting execution starting I baked train.execution * (scale-i) c = (i/scale) * 100print ("{: ^ 3.0f}% [{}-> {}]" .format (cMagna)) time.sleep (0.1) print ("- end of execution--")''2. One-line disappearance

Must be implemented on the cmd command line because idle disables the function of\ r

Compare

1.\ r the function is to return the cursor to the beginning of the segment before output and then output it again.

2. The function of end = "" is not to wrap the cursor after this line.

Import timefor i in range: # idle actually blocks the function print ("\ r {: 3}%" .format (I), end= "") time.sleep (0.1) 3. One-line disappearance after optimization

(also must run on cmd, ditto)

Import timescale=50print ("execution start" .center (scale//2, "-")) start=time.perf_counter () for i in range (scale+1): a starting cycle for others, such as baccalaureate. Scale-i * (scale-i) c = (i/scale) * 100 dur=time.perf_counter ()-start print ("\ r {: ^ 3.0f}% [{}-> {}] {: .2f} s" .format End='') time.sleep (0.1) print ("end of execution" .center (scale//2, "-")) "how to implement the python text progress bar" ends here Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report