[Tutor] FW: wierd replace problem
rwobben at hotmail.com
Tue Sep 14 16:29:10 CEST 2010
> From: steve at pearwood.info
> To: tutor at python.org
> Date: Tue, 14 Sep 2010 21:30:01 +1000
> Subject: Re: [Tutor] FW: wierd replace problem
> On Tue, 14 Sep 2010 05:38:18 pm Roelof Wobben wrote:
>>>> Strip ('"'') does not work.
>>>> Still this message : SyntaxError: EOL while scanning string
>> I understand what you mean but we're talking about a text-file which
>> will be read in a string. So I can't escape the quotes. As far as I
>> know I can't control how Python is reading a text-file with quotes.
> The text file has nothing to do with this. The text file is fine. The
> error is in the strings that YOU type, not the text file.
> Strings must have MATCHING quotation marks:
> This is okay: "abcd"
> So is this: 'abcd'
> But this is not: "abcd'
> You need to *look carefully* at strings you type and make sure that the
> start and end quotes match. Likewise you can't insert the SAME
> quotation mark in a string unless you escape it first:
> This is okay: "'Hello,' he said."
> So is this: '"Goodbye," she replied.'
> But this is not: 'He said "I can't see you."'
> But this is okay: 'He said "I can\'t see you."'
> Steven D'Aprano
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
I see the problem.
When I have this sentence : `'Tis so,' said the Duchess: `and the moral of that is--"Oh,
'tis love, 'tis love, that makes the world go round!"'
And I do string.strip() the output will be :
`'This and that one does not fit your explanation.
So I have to strip everything before I strip it.
More information about the Tutor