[Tutor] how to remove first '/'

vince spicer vinces1979 at gmail.com
Tue Aug 25 23:58:52 CEST 2009


On Tue, Aug 25, 2009 at 3:55 PM, <davidwilson at safe-mail.net> wrote:

> Hello,
> I want to strip the first '/' from the following:
>
> '/path/to/file'
>
> How can I do this?
>
> Dave
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>

there are many ways to do this, heres a few:

x = "/path/to/file"

print x.partition("/")[-1]
print x[1:]
print "/".join(x.split("/")[1:])
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090825/adc3fefb/attachment-0001.htm>


More information about the Tutor mailing list