[Tutor] shlex.split if there is an apostrophe in the string?

Jason Staudenmayer jasons at adventureaquarium.com
Fri Jan 7 20:34:02 CET 2011


> -----Original Message-----
> From: tutor-bounces+jasons=adventureaquarium.com at python.org 
> [mailto:tutor-bounces+jasons=adventureaquarium.com at python.org]
>  On Behalf Of Sean Carolan
> Sent: Friday, January 07, 2011 2:22 PM
> To: Tutor at python.org
> Subject: [Tutor] shlex.split if there is an apostrophe in the string?
> 
> 
> I'm practicing manipulating data with a text file.  I'm trying to use
> shlex.split to break up each line, which works great until it gets to
> the first apostrophe:
> 
> fin = open('huckfinn.txt')
> startstring = 'START OF THIS PROJECT'
> 
> for line in fin:
>     print line
>     words = shlex.split(line)
> 
> This is the line is where it's choking, complaining that there is no
> closing quote:
> 
> YOU don't know about me without you have read a book by the 
> name of The
> 
> How can I get shlex.split to ignore single apostrophes such 
> as the one above?
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
> 
WARNING Total newbie here.

Looks like you need to filter you data to excape the quote marks. I'm just learning so I'm not sure how to do that yet.

Jason
 
 
 
..·><((((º>


More information about the Tutor mailing list