作者:白珍茜登陆_585 | 来源:互联网 | 2023-05-17 20:11
I am trying to print in the exact same spot:
我想在同一个地方打印:
for i in range(10):
print("ok\r"),
However, this prints 10 oks in different lines:
但是,这会在不同的行中打印10个:
ok
ok
...
I tried putting the \r in the front of the string as well. In this case, I get a blank line then 10 oks:
我也尝试将\ r放在字符串的前面。在这种情况下,我得到一个空行然后10个月:
[blank]
ok
ok
...
I also tried the following
我也试过以下
import sys
for i in range(10):
sys.stdout.write('ok\r')
sys.stdout.flush()
But I get the same exact thing. I am on Python 2.7 in pyscripter, what am I doing wrong? I also tried in IDLE, and there 'okokokokokokokokokok' is the result when \r is on the end, and ' ok ok ok ok ok ok ok ok ok ok' is the result when it is in the front.
但我得到同样的东西。我在pyscripter中使用Python 2.7,我做错了什么?我也尝试过IDLE,并且'okokokokokokokokokok'是\ r \ n结束时的结果,'ok ok ok ok ok ok ok ok ok ok'是它在前面的结果。
Edit: I am on windows 7
编辑:我在Windows 7上
Any help is highly appreciated!
任何帮助都非常感谢!
2 个解决方案