I've just starting using python 2.7 and was using the following code to ascertain the path to a file:
import os, fnmatch
#find the location of sunnyexplorer.exe
def find_files(directory, pattern):
for root, dirs, files in os.walk(directory):
for basename in files:
if fnmatch.fnmatch(basename, pattern):
filename = os.path.join(root, basename)
yield filename
for filename in find_files('c:\users','*.sx2'):
print ('Found Sunny Explorer data in:', filename)
everthing seemed to be working fine until I tried to use the path and noticed an error. The program reports the path as:
c:\users\woody\Documents\SMA\Sunny Explorer
whereas the correct path is:
c:\users\woody\My Documents\SMA\Sunny Explorer