Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Overwrite text in python

# When you use print() in python, it always starts a newline.
# If you want to overwrite a line, you can move the cursor back to the beginning of the line

print("Testing 123", end="
") # 
 brings the cursor to the front of the string
print("Testing 456") # Will overwrite the last string
# OUTPUT: Testing 456

# NOTE
# The second string covers the first string. If the second is not long enough, you can see
# parts of the first string.
print("This is a very very long string", end="
")
print("Now it is shorter")
# OUTPUT: Now it is shorterry long string
Source by www.codegrepper.com #
 
PREVIOUS NEXT
Tagged: #Overwrite #text #python
ADD COMMENT
Topic
Name
8+8 =