split string problems

Andy Terrel andy.terrel at gmail.com
Thu Sep 7 19:49:39 EDT 2006


try str(p).split()[2]

your class is using the __str__ attribute to print and I am guessing
that is what you are seeing.

Tempo wrote:
> Hey. I am trying to grab the prices from the string below but I get a
> few errors when I try to do it: Take a look at the code and error
> messages below for me and thanks you in advanced to all that help.
> Thank you. Here's the code & error messages:
>
> >>> 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()[2]
>
> Traceback (most recent call last):
>   File "<pyshell#11>", line 1, in -toplevel-
>     p.split()[2]
> AttributeError: 'ResultSet' object has no attribute 'split'
> >>>




More information about the Python-list mailing list