how to truncate to get the 1st 5 chars from a string
Xavier Ho
contact at xavierho.com
Wed Sep 23 23:11:06 EDT 2009
On Thu, Sep 24, 2009 at 1:05 PM, MacRules <MacRules at none.com> wrote:
> s="1234abcd"
> s.range(0..4)
> 1234a
>
> Is there a string function like this?
>
>
Use the slice.
>>> s = "1234abcd"
>>> s[:5]
'1234a'
Cheers,
Xav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090924/ead25f82/attachment-0001.html>
More information about the Python-list
mailing list