Hack Forums
[Python] Text Manipulation and Printing - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Text Manipulation and Printing (/showthread.php?tid=6094689)



Text Manipulation and Printing - HardStoN - Jul 13, 2020

Hi,
Recently i came across a pretty cool printing technique that changes a specific word in a printed line without re printing the whole line again or clearing the console.
so u can use it for like counters or something like that. Does anyone know how to do that?

Thanks for the help


RE: Text Manipulation and Printing - omboml - Jul 13, 2020

something like this?
for x in range(100000): print(f"{x}\r",end="")


RE: Text Manipulation and Printing - HardStoN - Jul 13, 2020

🤣🤣🤣🤣🤣
Thank's man helped a lot!!!


But do u know a way that u can insert it into a line
so it would be like
print(f"Loading {x}\r Files...", end="")


RE: Text Manipulation and Printing - Anxuein - Jul 13, 2020

(Jul 13, 2020 01:58 PM)HardStoN Wrote:  🤣🤣🤣🤣🤣
Thank's man helped a lot!!!


But do u know a way that u can insert it into a line
so it would be like
print(f"Loading {x}\r Files...", end="")

For a new line you can just add a new line you can add a new line using "\n", so it would look like the following:
Code
print(f"Loading {x}\r Files...", end="\n")



RE: Text Manipulation and Printing - HardStoN - Jul 14, 2020

What i mean is that if i do as i posted the output is:
https://imgur.com/a/y2aEXxl

Instead of Loading 9999 Files...

what i posted is:
for x in range(100000):
print(f"Loading {x}\r Files", end="")


RE: Text Manipulation and Printing - Anxuein - Jul 14, 2020

(Jul 14, 2020 06:31 AM)HardStoN Wrote:  What i mean is that if i do as i posted the output is:
https://imgur.com/a/y2aEXxl

Instead of Loading 9999 Files...

what i posted is:
for x in range(100000):
   print(f"Loading {x}\r Files", end="")

Ah, I see what you mean. You can remove the "\r" and add it to the end, so it would look like:
Code
for x in range(1000000):
    print(f"Loading {x} Files", end="\r")