Python:Special Character

From Progzoo
Jump to: navigation, search

Double Quotes

You can use escape sequences for special characters such as

Backslash \\
New line  \n
Quote     \"
Tab       \t


[Font] [Default] [Show] [Resize] [History] [Profile]

Single Quotes

Note the escape sequences operate in single quoted strings (unlike perl and php).


[Font] [Default] [Show] [Resize] [History] [Profile]

Triple Double or Single Quotes

Using a triple set of Single or Double Quotes

"""Such as this"""
'''or this'''

allows you to use single or double quotes within the string without escaping them and formats whitespace as it appears in the string. Escape sequences still work.

These are usually used for doc strings in methods and classes.


[Font] [Default] [Show] [Resize] [History] [Profile]