Consider this line of Python code:
s = "This string has \n\r whitespace"
How do I make
print s
give me
This string has \n\r whitespace
instead of
This string has
whitespace
as it does now.
3 Answers. Show activity on this post. ~> myVar="Hi, there!"; printf '%20s\n' "$myVar" Hi, there! ~> myVar="Bye!"; printf '%20s\n' "$myVar" Bye!
Type df and press enter in a Bash terminal window to get started. You'll see a lot of output similar to the screenshot below. Using df without any options will display the available and used space for all mounted filesystems. At first glance, it might look impenetrable, but it is quite easy to understand.
Other languages mostly ignore whitespaces, Python doesn't.
What are whitespace characters in Python? In Python, characters that are used for spacing are called as whitespace characters. They include newline, spaces, tabs, carriage return, feed, etc. Whitespace is a string that has been pre-initialized and is used as a string constant.
do you want a raw string ?
s = r"This string has \n\r whitespace"
or to transform special characters to it's representation?
repr(s)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With