20050119: quoting strings
steve at holdenweb.com
Mon Jan 10 11:35:27 CET 2005
Xah Lee wrote:
> #strings are enclosed in double quotes quotes. e.g.
> a="this and that"
> print a
> #multiple lines must have an escape backslash at the end:
> and that"
> print b
> #One can use r"" for raw string.
> and that"
> print c
> #To avoid the backslash escape, one can use triple double quotes to
> print as it is:
> print d
> # in Perl, strings in double quotes acts as Python's triple """.
> # String is single quote is like Python's raw r"".
> # Alternatively, they can be done as qq() or q() respectively,
> #and the bracket can be just about any character,
> # matching or not. (so that escapes can be easy avoided)
> $a=q(here, everthing is literal, $what or \n or what not.);
> $b=qq[this is
> what ever including variables $a that will be
> evaluated, and "quotes" needn't be quoted.];
> print "$a\n$b";
> #to see more about perl strings, do on shell prompt
> #perldoc -tf qq
> xah at xahlee.org
Well, that gets that sorted out, then.
Tomorrow: using single quotes. Using single quotes. The larch.
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/
Holden Web LLC +1 703 861 4237 +1 800 494 3119
More information about the Python-list