No such file or directory error

后端 未结 6 1700
有刺的猬
有刺的猬 2021-01-13 13:20

This is the error I am getting:

Traceback (most recent call last):
  File \"E:\\stuff\\module.py\", line 91, in 
    f = open(\'E:/stuff/log.tx         


        
6条回答
  •  独厮守ぢ
    2021-01-13 13:45

    it been a long time that i didn't use windows, but if i remember well windows use back-slash in system path so you should do:

    import os
    
    file_name = os.path.join("e:\\stuff", "log.txt")
    
    f = open(file_name)
    

    and not:

    f = open('E:/stuff/log.txt')
    

    there is not / in paths in windows.

提交回复
热议问题