回归Python计数器
我正在用Python(控制台)做一个小型周末项目,一种音乐播放器。我已经完成了选择音乐、解析 ID3 标签、播放和 blablabla 的所有部分。我只是想我需要像计数器这样的东西来显示音乐的总时间和播放时间。
基本上我需要的是打印一个字符串,仅删除该字符串并再次打印它。我不在乎是否需要任何外部库,但我需要它是 Windows(如果存在)。
那么,有什么办法可以在Python上做到这一点吗? 提前致谢。
i was doing a small weekend project, kind of a music player, in python (console). I'm done in all the part of selecting music, parsing ID3 tags, playing and blablabla. I just think i need something like a counter to show the music's total time and played time.
Basically what i need is to print a string, erase only that string and print it again. I don't care if i need any external libraries for this, but i need it to be windows if exists.
So, is there any way to do this on python?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该查看curses 模块,它提供了对控制台的更多控制。它内置于 python 中。
编辑
显然标准库curses在Windows上不可用,但你可以看看使用这个:http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses
但更简单的策略是使用“\b”,它是一个退格字符。
没有输出,因为 a 被擦除。你也许可以用它。
You should look at the curses module which provides more control over the console. It is built into python.
EDIT
Apparently the standard library curses isn't available on Window, but you can look at using this: http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses
But a simpler strategy is to use "\b" it is a backspace character.
Has no output because the a is erase. You might be able to use that.