2015-04-12 14 views

回答

4

隨着os.path.splitdrive

In [1]: import os 

In [2]: drive, tail = os.path.splitdrive(r'D:\John\myfolder\newfolder') 

In [3]: tail 
Out[3]: '\\John\\myfolder\\newfolder' 
0

你可以用切片。

>>> path = r"D:\John\myfolder\newfolder" 
>>> print(path[3:]) 
John\myfolder\newfolder 
相關問題