小终端微调器库。
pyspin的Python项目详细描述
一个小小的终端微调器库。深受go-spin启发。
演示
安装
$ pip install pyspin
用法
手工制作微调器:
from__future__importprint_functionimportsysimporttimefrompyspin.spinimportDefault,Spinner# Choose a spin style.spin=Spinner(Default)# Spin it now.foriinrange(50):print(u"\r{0}".format(spin.next()),end="")sys.stdout.flush()time.sleep(0.1)
或者您可以使用decorator pyspin提供:
from__future__importprint_functionimporttimefrompyspin.spinimportmake_spin,Default# Choose a spin style and the words when showing the spin.@make_spin(Default,"Downloading...")defdownload_video():time.sleep(10)if__name__=='__main__':print("I'm going to download a video, and it'll cost much time.")download_video()print("Done!")
您可以查看example文件夹中的示例代码。运行它 通过:
$ python example/example_spin.py $ python example/usage_example.py
贡献
- 如果您发现一个有趣的微调器,请发送一个拉取请求<;3
- 如果你发现一个bug或者有任何建议,打开一个问题。
随时欢迎投稿!
许可证
麻省理工学院。