Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Python: Check if a string begins or ends with a specific prefix or suffix

Python: Check if a string begins or ends with a specific prefix or suffix
{filelink=16181}

import os
myDir="."
for f in os.listdir(myDir): # list current dir
    if f.endswith('.py'):
        print "Python file: " + f
    elif f.endswith('.txt'):
        print "Text file: " + f

Users who found this page were searching for:

  • python string ends with
  • python if element ends with /
  • python f endswith
  • python check string ends with
  • endswith function python

No comments yet.

Leave a Comment