About 8,770,000 results
Open links in new tab
  1. python - Find the current directory and file's directory - Stack …

    How do I determine: the current directory (where I was in the shell when I ran the Python script), and where the Python file I am executing is?

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

    Jul 9, 2010 · How can I list all files of a directory in Python and add them to a list?

  3. How do I find the location of my Python site-packages directory?

    The per user site-packages directory (PEP 370) is where Python installs your local packages: python -m site --user-site If this points to a non-existing directory check the exit status of …

  4. How do I change the working directory in Python? - Stack Overflow

    cd is the shell command to change the working directory. What is the equivalent in Python?

  5. How can I list the contents of a directory in Python?

    May 3, 2010 · 15 The os module handles all that stuff. os.listdir(path) Return a list containing the names of the entries in the directory given by path. The list is in arbitrary order. It does not …

  6. How do I check if a directory exists in Python? - Stack Overflow

    26 We can check with 2 built in functions os.path.isdir("directory") It will give boolean true the specified directory is available. os.path.exists("directoryorfile") It will give boolead true if …

  7. How can I delete a file or folder in Python? - Stack Overflow

    Deleting a file or folder in Python There are multiple ways to delete a file in Python but the best ways are the following: os.remove() removes a file. os.unlink() removes a file. It is a Unix alias …

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

    The above answer assumes the most common scenario of running a python script that is in a file. References pathlib in the python documentation. os.path - Python 2.7, os.path - Python 3 …

  9. What is the best project structure for a Python application?

    Python doesn't have a distinction between /src, /lib, and /bin like Java or C has. Since a top-level /src directory is seen by some as meaningless, your top-level directory can be the top-level …

  10. python - How can I iterate over files in a given directory? - Stack ...

    Apr 30, 2012 · I need to iterate through all .asm files inside a given directory and do some actions on them. How can this be done in a efficient way?