You can get the drive and path+file like this:
drive, path_and_file = os.path.splitdrive(path)
Get the path and the file:
path, file = os.path.split(path_and_file)
第二种方法 os.path.normpath
import os
path = os.path.normpath(path)
path.split(os.sep)
var = “d:\stuff\morestuff\furtherdown\THEFILE.txt”
[ “d”, “stuff”, “morestuff”, “furtherdown”, “THEFILE.txt” ]