text - Python: Searching for exact filename -


in searching html within current directory, if name contains substring assume file exists , continue operation instead of saying file doesn't exist. have file "protocolhttp.html" - in testing make sure "protocol.html" throws error, doesn't. continues operation of program.

i make sure filename matches exactly. here's have:

for file in glob.glob('*.html'):         if protocolfile in file:                 open(file) f:                         contents = f.read()         else:                 print "could not locate '" + protocolfile + ".html'"                 sys.exit(1) 

any ideas or further steps check validate this?

i think code same thing as:

if os.path.isfile(filename):     open(filename) f:         contents = f.read() else:     print 'could not locate {0}'.format(filename)     sys.exit(1) 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -