String parsing
Tim Leslie
tim.leslie at gmail.com
Tue May 8 21:54:31 EDT 2007
On 8 May 2007 18:09:52 -0700, HMS Surprise <john at datavoiceint.com> wrote:
>
> The string below is a piece of a longer string of about 20000
> characters returned from a web page. I need to isolate the number at
> the end of the line containing 'LastUpdated'. I can find
> 'LastUpdated' with .find but not sure about how to isolate the
> number. 'LastUpdated' is guaranteed to occur only once. Would
> appreciate it if one of you string parsing whizzes would take a stab
> at it.
>
Does this help?
In [7]: s = '<input type="hidden" name="LastUpdated"
value="1178658863"/>'
In [8]: int(s.split("=")[-1].split('"')[1])
Out[8]: 1178658863
There's probably a hundred different ways of doing this, but this is
the first that came to mind.
Cheers,
Tim
> Thanks,
>
> jh
>
>
>
> <input type="hidden" name="RFP" value="-1"/>
> <!--<input type="hidden" name="EnteredBy" value="johnxxxx"/>-->
> <input type="hidden" name="EnteredBy" value="john"/>
> <input type="hidden" name="ServiceIndex" value="1"/>
> <input type="hidden" name="LastUpdated" value="1178658863"/>
> <input type="hidden" name="NextPage" value="../active/active.php"/>
> <input type="hidden" name="ExistingStatus" value="10" ?>
> <table width="98%" cellpadding="0" cellspacing="0" border="0"
> align="center"
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list