I am trying to get the the file name along with extension from a path I tried few codes but I am unable to get the file name.
filename = '/home/lancaster/Downloads/a.ppt'
extention = filename.split('/')[-1]
This works fine for the file path given there but when I try for file path which has '\' backward slash it takes it as an escape sequence and throws this error EOL while scanning string literal
filename = '\home\lancaster\Downloads\a.ppt'
extention = filename.split('\')[-1]
This throws error EOL while scanning string literal
filename = '\home\lancaster\Downloads\a.ppt'
extention = filename.split('\')[-1]
Expected result is
a.ppt
but throws
'EOL while scanning string literal'