Searching Strings for Specific Endings/Beginnings : Endswith : String PYTHON TUTORIALS


PYTHON TUTORIALS » String » Endswith »

 

Searching Strings for Specific Endings/Beginnings


import os

for f in os.listdir('C:\txtfiles'):
    if f.endswith('.py'):
        print "Python file: " + f
    elif f.endswith('.txt'):
        print "Text file: " + f



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo String
» Endswith