'How to print multi line text box value without '\n' by tkinter
I want to print textbox value without '\n' from tkinter, When I print then it show one line and next line valu adding with "\n', actually I fetch the valu from mysql
Solution 1:[1]
To remove a \n from the end of a string, use rstrip('\n'):
lines = [
"Hello, world!\n",
"No newline",
"", # empty
"Two\nNewlines\n",
"Intermediate\nNewline",
]
for line in lines:
s = line.rstrip("\n")
print("-" * 20)
print(s)
# gives
"""
--------------------
Hello, world!
--------------------
No newline
--------------------
--------------------
Two
Newlines
--------------------
Intermediate
Newline
"""
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jack Deeth |
