更新时间:2023-11-25 20:21:46
The .listdir()
method gives you filenames without paths only, you are probably trying to open a file in the current directory, not in the directory named by path
.
You have to use the os.path.join
function to put path
and item
together:
for item in added:
print item
fullfilename = os.path.join(path, item)
ad=open(fullfilename,'r')
print ad.read()