>>> a='/root/pythondemo/demo12/stringcut' >>> a.split('/')[-1] 'stringcut' >>> import os.path >>> os.path.basename(a) 'stringcut'