Python進度條程式展示方案

來源:互聯網
上載者:User

標籤:python   有關   pycha   linux系統   res   多少   sleep   自己   rom   

 

# 說明下面我們有時候運行代碼的時候會出現幾個進度條,我在pycharm上當我把sleep設定太小的時候會出現這種情況,把sleep設定大點就好了# 要想設定小點也不會出現問題,那麼可以在Windows下的dos命令列下運行,也可以使用別的編譯器或者換成Linux系統。也有可能你的pycharm不會出現這個問題。# 這個只是說明一下出現的結果不一樣的時候,不是代碼有問題,有可能與你的編譯器有關。下面代碼都是自己親測有效。# 使用tqdm模組裡from tqdm import tqdmimport timefor i in tqdm(range(20)):    time.sleep(0.5)100%|██████████| 20/20 [00:10<00:00,  2.00it/s]import timefor i in range(0,101,2):     char_num = i//2      #列印多少個‘*‘     per_str = ‘\r%s%% : %s\n‘ % (i, ‘*‘ * char_num) if i == 100 else ‘\r%s%% : %s‘%(i,‘*‘*char_num)     print(per_str,end=‘‘, flush=True)     time.sleep(0.3)#上面的\r表示每次輸出的內容返回到第一個指標,就是每次在行首輸出#100% : **************************************************import timeimport sysfor i in range(11):    print("\r進度:%s%%"%(i*10), end="")    time.sleep(0.4)# 進度:100%for i in range(11):    time.sleep(0.1)    sys.stdout.write("\r進度%s%%:%s"%(i*10,i * ‘*‘))# 進度100%:**********import timeimport progressbarp = progressbar.ProgressBar()for i in p(range(10)):    time.sleep(0.2)#  100% |########################################################################

 

Python進度條程式展示方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.