且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

IOError:[Errno 13]权限被拒绝,同时打开一个文件

更新时间: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()

相关阅读

推荐文章