[Tutor] Problem Stripping

leam hall leamhall at gmail.com
Fri Mar 30 19:09:39 CEST 2012


Python 2.4.3 on Red Hat 5. Trying to use strip to remove characters
but it doesn't seem to work like I thought.


res = subprocess.Popen(['uname', '-a'], stdout=subprocess.PIPE)
uname = res.stdout.read().strip()

>>> uname
'Linux myserver 2.6.18-274.el5PAE #1 SMP Fri Jul 8 17:59:09 EDT 2011
i686 i686 i386 GNU/Linux'

>>> uname.strip(':')
'Linux myserver 2.6.18-274.el5PAE #1 SMP Fri Jul 8 17:59:09 EDT 2011
i686 i686 i386 GNU/Linux'

>>> 'www.example.com'.strip('cmowz.')
'example'

Thoughts?

Leam
-- 
Mind on a Mission <http://leamhall.blogspot.com/>


More information about the Tutor mailing list