About 50 results
Open links in new tab
  1. python - Find the current directory and file's directory - Stack Overflow

    394 Current working directory: os.getcwd() And the __file__ attribute can help you find out where the file you are executing is located. This Stack Overflow post explains everything: How do I get the path of …

  2. python - How to reliably open a file in the same directory as the ...

    Closed 2 years ago. I used to open files that were in the same directory as the currently running Python script by simply using a command like:

  3. python - How do I list all files of a directory? - Stack Overflow

    Jul 9, 2010 · 3464 This question's answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions. How can I list all files of a directory in …

  4. Browse files and subfolders in Python - Stack Overflow

    Apr 28, 2011 · The first parameter is the directory pathname. This will change for each subdirectory. This answer is based on the 3.1.1 version documentation of the Python Library. There is a good …

  5. python - How do I get the full path of the current file's directory ...

    2814 The special variable __file__ contains the path to the current file. From that we can get the directory using either pathlib or the os.path module. Python 3 For the directory of the script being run:

  6. how to check if a file is a directory or regular file in python ...

    Jul 18, 2016 · Technically, all file system objects are files. A directory is a file but of a special type on most file systems. Then there are devices, pipes, sockets, etc. The os.stat() method in this answer is …

  7. Open File in Another Directory (Python) - Stack Overflow

    Sep 9, 2015 · Do you need to set the current directory to subfldr1 and open the file inside? Or do you only need to open the file, but whether your current directory has changed does not matter?

  8. How do I fix the "No File or Directory issue" python?

    May 22, 2020 · The file is not found because it is looking in the current directory, which is not the same directory where your script lives. Depending on how you run Python, the current directory might be …

  9. Find a file in python - Stack Overflow

    Nov 12, 2009 · I have a file that may be in a different place on each user's machine. Is there a way to implement a search for the file? A way that I can pass the file's name and the directory tree to search …

  10. python - open () gives FileNotFoundError / IOError: ' [Errno 2] No such ...

    Ensure the file exists (and has the right file extension): use os.listdir() to see the list of files in the current working directory. Ensure you're in the expected directory using os.getcwd().