Newbie problem with user input

Chris McMillan christopherjmcmillan at eaton.com
Wed Jul 11 09:09:52 EDT 2001


Hello all!  The partial code below prompts a user to enter a path.  I then
want it to find (and later do something with) all the files in that
directory matching the specified string.  The problem is that when I run the
script, and enter, for example D:\test it does not find any of the files.  I
believe it is because the glob command is searching for ''D:\\test'\\*.dat'
With the extra single quotes.  How can I get it to search for
'D:\\test\\*.dat' ?  Thanks!
Chris


print 'Enter the path:'                  # prompt user for directory path
path = raw_input()
for fname in glob.glob('path\\*.dat'):   # finds files matching string







More information about the Python-list mailing list