Errno 2 python找不到文件错误

时间:2016-11-29 15:46:40

标签: python errno pyzo

程序是

with open ('D:\\Users\\gracelewis\\Desktop\\data\\input_data2.txt','r') as data2:
    with open ('D:\\Users\\gracelewis\\Desktop\\data\\input_names.txt','r') as names:
        with open ('D:\\Users\\gracelewis\\data\\output_data_merged.txt','w') as output_data: 
            tempstring1 = (data2.readlines())
            tempstring2 = (names.readlines())
            list1 = list(tempstring1)
            list2 = list(tempstring2)
            mulitilist1 = (list1+list2)
            print(multilist1)
            output_data.writelines(multilist)

我收到了这个错误 -

Traceback (most recent call last):
  File "/Users/gracelewis/Documents/Documents/University/data/Option2.py", line 2, in <module>
    with open ('D:\\Users\\gracelewis\\Desktop\\data\\input_data2.txt','r') as data2:
FileNotFoundError: [Errno 2] No such file or directory: 'D:\\Users\\gracelewis\\Desktop\\data\\input_data2.txt'

1 个答案:

答案 0 :(得分:1)

这正是它所说的 - 你没有文件路径的文件

'D:\\Users\\gracelewis\\Desktop\\data\\input_data2.txt'