Py之reprint:reprint的简介、安装、使用方法之详细攻略
生活随笔
收集整理的這篇文章主要介紹了
Py之reprint:reprint的简介、安装、使用方法之详细攻略
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Py之reprint:reprint的簡介、安裝、使用方法之詳細攻略
?
?
目錄
reprint的簡介
reprint的安裝
reprint的使用方法
?
?
?
reprint的簡介
? ? ? reprint 是一個適用于 Python3 的簡易變量綁定與多行輸出刷新的庫。特性 + 簡易變量綁定,內容修改時自動刷新命令行輸出 + 多行輸出刷新,實現不同行內容由獨立變量控制,修改特定變量即能刷新命令行中特定行的內容 + 多線程安全,使用了 threading.Lock 實現線程安全 + 無外部庫依賴。
py pi地址:https://pypi.org/project/reprint/
?
?
reprint的安裝
pip install reprint
reprint的使用方法
1、官方示例
import time import random import threadingfrom reprint import outputdef some_op(index=0):LENGTH = 100global output_listnow = 0while now < LENGTH:max_step = LENGTH-nowstep = random.randint(1, max_step or 1)now += stepoutput_list[index] = "{}{}{padding}{ending}".format("-" * now,index,padding=" " * (LENGTH-now-1) if now < LENGTH else "",ending="|" if now < LENGTH else "")time.sleep(1)output_list.append("{} finished".format(index))with output(output_type="list", initial_len=5, interval=0) as output_list:pool = []for i in range(5):t = threading.Thread(target=some_op, args=(i,))t.start()pool.append(t)[t.join() for t in pool]?
總結
以上是生活随笔為你收集整理的Py之reprint:reprint的简介、安装、使用方法之详细攻略的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ML之Clustering之H-clus
- 下一篇: RL之Q Learning:利用强化学习