infile1 = open("D:/p/non_rte_header_path.txt","r")
infile2 = open("D:/p/fnsinrte.txt","r")
for line in infile1:
for item in infile2:
eachfile = open(line,"r")
对于上述代码我得到下面的错误。 infile1包含5文件,如d路径:/folder/Src/em.h但在这里\ n自动处于path.I结束我不知道为什么会发生。请帮忙。IO错误22蟒
IOError: [Errno 22] invalid mode ('r') or filename: 'D:/folder/Src/em.h\n'
'\ N'应该给你一些提示,你忘了去掉尾随换行符。 – dhke
尝试在尝试打开它之前修剪“行”。 – Maroun
您需要剥离换行符所以'line.rstip( '\ n')'将工作 – EdChum