Suppose I have a path like C:\\exportDir\\testing\\content\\catalog\\root\\shared\\First\\First_content\\Report1
How can I retreive the child filename in my case Report1
without using split by \\
Suppose I have a path like C:\\exportDir\\testing\\content\\catalog\\root\\shared\\First\\First_content\\Report1
How can I retreive the child filename in my case Report1
without using split by \\
Yes.
Use os.path.split()
Example:
import os
# path
path = '/home/User/Desktop/file.txt'
# Split the path in
# head and tail pair
head_tail = os.path.split(path)
# print head and tail
# of the specified path
print("Head of '% s:'" % path, head_tail[0])
print("Tail of '% s:'" % path, head_tail[1], "\n")