#From stacoverflow: url = 'http://www.test.com/TEST1' last = url.rsplit('/', 1)[-1] print(last) #TEST1