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'