Python:Special Character

From Progzoo
Revision as of 16:56, 24 February 2009 by 08003008 (talk | contribs) (Added section on triple quoting.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to 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]