How to specify a path platform-independently in Python

Paths in Windows use “\” while paths in Unix operating systems use “/”. By referring to paths independent of the current platform, the script can work on filesystems operating under both operating systems.

Solution for How to specify a path platform-independently in Python : You can use pathlib.Path specify a path platform independently Create a pathlib.Path(directory, file) object to access a file from a directory. The type of path will be selected automatically based on the current operating system.


how-to-specify-a-path-platform-independently-in-python