Skip to content

Instantly share code, notes, and snippets.

@hoang-himself
Last active January 31, 2021 01:21
Show Gist options
  • Save hoang-himself/1a952f5f09a400c4061f6092c932c03f to your computer and use it in GitHub Desktop.
Save hoang-himself/1a952f5f09a400c4061f6092c932c03f to your computer and use it in GitHub Desktop.
Python split path
import ntpath
def path_leaf(path):
head, tail = ntpath.split(path)
return tail or ntpath.basename(head)
if __name__ == '__main__':
path = '/content/My Drive/ocr_demo_test/act_data/Page_1.jpg'
print(path_leaf(path))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment