Skip to content

Instantly share code, notes, and snippets.

@Yagisanatode
Created May 29, 2015 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yagisanatode/6564668285670d0839e7 to your computer and use it in GitHub Desktop.
Save Yagisanatode/6564668285670d0839e7 to your computer and use it in GitHub Desktop.
Python - Finding an Item Between Two Characters In a String Using: partition and rpartition
'''
Finding an Item Between Two Characters In a String Using:
partition and rpartition
This could be handy for file creation and checking.
'''
file = 'batman(0).jpg'
file.partition('(')[-1].rpartition(')')[0]
'''
RESULT:
'0'
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment