Jump to content

Recommended Posts

Posted
import os 
full_path = '/home/User/Documents/file.txt'  
head_tail = os.path.split(full_path)  
print (f"The full path is '{full_path}’") 
print (f"The path is '{head_tail[0]}'") 
print(f"and the file name is '{head_tail[1]}’ ") 
output:

The full path is '/home/User/Documents/file.txt’ 
The path is '/home/User/Documents' 
and the file name is 'file.txt  

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...