In [1]:
import ntpath
In [2]:
print(ntpath.sep)
In [3]:
print('\\')
In [4]:
print(ntpath.sep is '\\')
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)
In [7]:
print(ntpath.basename(file_path))
In [8]:
print(ntpath.dirname(file_path))
In [9]:
print(ntpath.split(file_path))
In [10]:
print(ntpath.splitdrive(file_path))
In [11]:
drive_letter = ntpath.splitdrive(file_path)[0][0]
print(drive_letter)
In [12]:
print(ntpath.join('c:', 'dir', 'subdir', 'filename.ext'))
In [13]:
print(ntpath.join('c:', ntpath.sep, 'dir', 'subdir', 'filename.ext'))
In [14]:
print(ntpath.join('c:\\', 'dir', 'subdir', 'filename.ext'))