Print forward slash in python
You need to escape your backslash by preceding it with, yes, another backslash: Show
And for versions prior to Python 3:
The As you can probably guess, See the Python 3 documentation for string literals. On this page: commenting with #, multi-line strings with """ """, printing multiple objects, the backslash "\" as the escape character, '\t', '\n', '\r', and '\\'. Video Tutorial
Video Summary
Learn More
PracticeThere are at least three ways to print I'm hugry. What are they? Try in IDLE shell. There are at least three ways to print Fleas, Adam, Had'em (the shortest
English poem ever written apparently) in three separate lines, using one print() function. What are they? Try in IDLE shell. Explore
How do you print a front slash in Python?Use the syntax "\\" within the string literal to represent a single backslash.
How do you print backslash and forward slash in Python?For completeness: A backslash can also be escaped as a hex sequence: "\x5c" ; or a short Unicode sequence: "\u005c" ; or a long Unicode sequence: "\U0000005c" . All of these will produce a string with a single backslash, which Python will happily report back to you in its canonical representation - '\\' .
How do you do a slash in Python?In Python strings, the backslash "\" is a special character, also called the "escape" character. It is used in representing certain whitespace characters: "\t" is a tab, "\n" is a newline, and "\r" is a carriage return. Conversely, prefixing a special character with "\" turns it into an ordinary character.
What is forward slash in Python?Use Forward slash / to break code into multiline code. Line break means code line change in Python, but you can use forward slash / to bluff python. You can easily break your code into multiple lines using forward slash in between.
|