split string problems

John McMonagle jmcmonagle at velseis.com.au
Fri Sep 8 01:48:03 CEST 2006


On Thu, 2006-09-07 at 16:21 -0700, Tempo wrote:
> [<span class="sale">
>                                         $14.99
>                                 </span>, <span class="sale">
>                                         $27.99
>                                 </span>, <span class="sale">
>                                         $66.99
>                                 </span>, <span class="sale">
>                                         $129.99
>                                 </span>, <span class="sale">
>                                         $254.99
>                                 </span>]

Worked alright for me (see below).  Are you sure "p" is a string ?

Cut and paste from interactive python shell:

>>> p = """
... [<span class="sale">
...                                         $14.99
...                                 </span>, <span class="sale">
...                                         $27.99
...                                 </span>, <span class="sale">
...                                         $66.99
...                                 </span>, <span class="sale">
...                                         $129.99
...                                 </span>, <span class="sale">
...                                         $254.99
...                                 </span>]"""
>>> p.split()
['[<span', 'class="sale">', '$14.99', '</span>,', '<span',
'class="sale">', '$27.99', '</span>,', '<span', 'class="sale">',
'$66.99', '</span>,', '<span', 'class="sale">', '$129.99', '</span>,',
'<span', 'class="sale">', '$254.99', '</span>]']
>>> p.split()[2]
'$14.99'
>>>

Regards,

John


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




More information about the Python-list mailing list