Splitting Pathnames : Path : Development PYTHON examples


PYTHON examples » Development » Path »

 

Splitting Pathnames


Splitting Pathnames

import os 

os.path.split("c:\music\ap\m.mp3")         

(filepath, filename= os.path.split("c:\music\ap\m.mp3"

print filepath                                                     

print filename                                                     

(shortname, extension= os.path.splitext(filename)                

print shortname 

print extension 

# The split function splits a full pathname and returns a tuple containing the path 
# and filename. 


# os.path also contains a function splitext, which splits a filename and returns a 
# tuple containing the filename and the file extension. 
           
       



    Related Scripts with Example Source Code in same category :

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Development
» Path