may be a bug in string.rstrip

Ant antroy at gmail.com
Fri Nov 23 05:11:34 EST 2007


On Nov 23, 4:09 am, "kyo guan" <kyog... at gmail.com> wrote:
...
> >>> '120.exe'.rstrip('.exe')

Another approach since you seem to be working with filenames is using
the os.path module:

>>> import os.path as path
>>> s = "test.torrent"
>>> t = "test.exe"
>>> u = "test"
>>> path.splitext(s)[0]
'test'
>>> path.splitext(t)[0]
'test'
>>> path.splitext(u)[0]
'test'



More information about the Python-list mailing list