In [1]:
import ntpath

In [2]:
print(ntpath.sep)


\

In [3]:
print('\\')


\

In [4]:
print(ntpath.sep is '\\')


True

In [5]:
file_path = 'c:\\dir\\subdir\\filename.ext'
file_path_raw = r'c:\dir\subdir\filename.ext'

In [6]:
print(file_path == file_path_raw)


True

In [7]:
print(ntpath.basename(file_path))


filename.ext

In [8]:
print(ntpath.dirname(file_path))


c:\dir\subdir

In [9]:
print(ntpath.split(file_path))


('c:\\dir\\subdir', 'filename.ext')

In [10]:
print(ntpath.splitdrive(file_path))


('c:', '\\dir\\subdir\\filename.ext')

In [11]:
drive_letter = ntpath.splitdrive(file_path)[0][0]

print(drive_letter)


c

In [12]:
print(ntpath.join('c:', 'dir', 'subdir', 'filename.ext'))


c:dir\subdir\filename.ext

In [13]:
print(ntpath.join('c:', ntpath.sep, 'dir', 'subdir', 'filename.ext'))


c:\dir\subdir\filename.ext

In [14]:
print(ntpath.join('c:\\', 'dir', 'subdir', 'filename.ext'))


c:\dir\subdir\filename.ext