Trimming a string

Double Dumbass on You spam_me_gently_with_a_chainsaw at yahoo.com
Mon Aug 2 11:54:45 EDT 2004


Thanks for the tip.


"Tim Williams" <listserver at tdw.net> wrote in message
news:mailman.1055.1091461210.5135.python-list at python.org...
> >I have a string that is 7 characters and represents file mode in
UNIX/LINUX
> from rpm:
>
> >0100755
>
> >I don't care about the 0100 portion, I am only interested in the file
> >permissions portion which is 755.  How can I get three characters from
the
> >string starting at the right?  ( -OR- strip 4 characters from the left? )
>
>
>
> >>> str = "0100755"
> >>> str1 = str[4:]
> >>> print str1
> 755
> >>> str2 = str[-3:]
> >>> print str2
> 755
> >>>





More information about the Python-list mailing list