Error with double backslash in Windows path in Python

后端 未结 2 557
清歌不尽
清歌不尽 2020-12-11 06:06

I want to work with paths in Windows in Python 3.3, but I have an error:

FileNotFoundError: [Errno 2] No such file or directory: \'E:\\\\dir\\\\.

2条回答
  •  甜味超标
    2020-12-11 06:39

    Changing '\\' for '/' worked for me. I created a directory named 'a' in C:/ for this example.

    >>> (Python interpreter)
    >>> import os
    >>> os.path.isdir('C:/a/)')
    >>> True
    >>> os.path.isfile('C:/a/)')
    >>> False
    

提交回复
热议问题