2.我们常看到自 己电脑上的文件路径如’C:\Windows\L ogsldosvc ,请将该路径分割为不同的文件夹
用字符串分隔
str1="C:\Windows\L ogsldosvc"
pathlist = str1.split("\\")
print(pathlist)
如果不想要C:的话,先分隔获取:后面的字符串,再根据\再分隔
str1="C:\Windows\L ogsldosvc"
pathlist = str1.split(":")[1].split("\\")
print(pathlist)