import os.path
spath="D:/360Downloads/testFile1/folder2/testFile1.txt"
#case 1:
p,f=os.path.split(spath);
print("dir is:" + p)
print("file is:" + f)
#case 2:
drv,left=os.path.splitdrive(spath);
print("drive is:" + drv)
print("left is:" + left)
#case 3:
f,ext = os.path.splitext(spath);
print("f is:" + f)
print("ext is:" + ext)
时间: 2024-12-28 21:09:47