python-3.x - Noob Question How would I update a print a function's output without creating a new line in my term in python3?
问题描述
I'm not exactly sure how to word this to be honest, but here's a simplified version of my current code.
for idx in range(0,11):
print('Failed:',idx)
This outputs:
Failed: 0
Failed: 1
Failed: 2
Failed: 3
Failed: 4
Failed: 5
Failed: 6
Failed: 7
Failed: 8
Failed: 9
Failed: 10
I'm trying to replace the original int with the next int in the range instead of spamming my terminal with a new line for every int in the range.
How could I update "Failed: 1" to "Failed: 2" without creating a new line for "Failed: 2"?
Sorry if this is poorly worded, if you're willing to help me but like me to elaborate further please say so and I will try my best.
解决方案
函数 print 需要第二个参数来指定 print 在行尾应该做什么
print("Text here", end="")
推荐阅读
- json - 递归jsonSchema最大调用栈
- html - 我的下拉菜单在悬停时不会保持打开状态
- python-3.x - 在 Python 中的每个指定分隔符之间插入下一行
- julia - @with_kw 在 Julia 中做了什么?
- reactjs - Jest 快照测试在本地通过但在 Jenkins 上失败
- sql - plsql减去同一张表中的列
- android - React Native 热重载
- c# - AspNetCore 3.1:处理注入服务构造函数中抛出的异常
- plsql - PL/SQL DBMS_OUTPUT.PUT_LINE
- python - 如何在 discord.py 中找到默认通道来发送起始消息?