下面的代码是我正在编写的程序的一部分,它在每个.py,.sh上运行一个方法。或.pl文件在目录及其文件夹中。Python IOError:[递归目录2]来自递归目录调用
for root, subs, files in os.walk("."):
for a in files:
if a.endswith('.py') or a.endswith('.sh') or a.endswith('.pl'):
scriptFile = open(a, 'r')
writer(writeFile, scriptFile)
scriptFile.close()
else:
continue
在编写程序时,它曾在目录树中我写的,但是当我移动到另一个文件夹试试那里,我得到这个错误信息:
Traceback (most recent call last):
File "versionTEST.py", line 75, in <module>
scriptFile = open(a, 'r')
IOError: [Errno 2] No such file or directory: 'enabledLogSources.sh'
我知道奇怪的事情是怎么回事,因为该文件是最肯定有...
是你的测试目录中的多个层次深?启用LogSources.sh从您运行此脚本的目录下层? – Hoopdady
'open(os.path.join(“{}/{}”。format(root,a)),“r”)' –
'writeFile'从哪里来? –