os.path.join combines directory and filename components into one pathname using the conventions of the current operating system. Importing os is sufficient; no separate os.path import is required. section 12.2.4
Use it to build paths without writing operating-system-specific separators:
- Pass existing subpaths as components; the function joins them into a longer pathname. section 12.2.4
The same construction across systems
path1 = os.path.join('mydir', 'bin') path2 = os.path.join('utils', 'disktools', 'chkdisk') os.path.join(path1, path2) On Windows, the result uses backslashes; on Linux, it uses forward slashes.


