Hot to split string literals that will across two or more lines ?
Xiao Jianfeng
fdu.xiaojf at gmail.com
Thu Nov 17 22:30:24 EST 2005
jmdeschamps at gmail.com wrote:
>Xiao Jianfeng wrote:
>
>
>>Hi,
>>
>>I need to print a long sting, which is two long so it must expand two
>>lines.
>>I know that we can use backslash(\) to explicitly join two lines into a
>>logical line,
>>but this doesn't work for string literals :(
>>
>>my code:
>>-----------------------------------------------------------------------------
>>if sth.:
>>print "a string whcih is very very looooooooooooooooooooooooooooooooooo\
>>oooooooooooooooooooong."
>>-----------------------------------------------------------------------------
>>
>>If I don't break the line, it will be very ugly, if I break the
>>line,....but how ?
>>
>>Thanks in advance!
>>
>>
>in python there are triple quoted strings:
>strVar = """this the beginning
>and this is the end """
>
>
Thanks.
But even I use triple quoted strings instead , there is still extra
space before "and this...".
The string I want to print is in a "if" statement, so it is not at the
beginning of the line.
>>xiaojf
>>
>>
>
>
>
More information about the Python-list
mailing list