About 314,000 results
Open links in new tab
  1. python - How do I remove/delete/replace a folder that is not empty ...

    Also note that even if the directory was empty, os.remove would fail again, because the correct function is os.rmdir .

  2. pathlib.Path vs. os.path.join in Python - Stack Overflow

    Apr 15, 2021 · When I need to define a file system path in my script, I use os.path.join to guarantee that the path will be consistent on different file systems: from os import path path_1 …

  3. python - How to install the os module? - Stack Overflow

    os is a standard Python module, there's no need install it. So import os should always work inside Python, and if it doesn't, the cause is your PYTHONPATH or IDE settings, look at them; don't …

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

    On Python 3.3 and below, you can use these methods instead of the pathlib ones: os.remove() removes a file. os.unlink() removes a symbolic link. os.rmdir() removes an empty directory.

  5. How to retrieve environment variables from .env using built-in "os ...

    Mar 7, 2023 · os.getenv('key') looks for 'key' in environmental variables. By default key-value pairs that are in .env file are not loaded into environment variables. If you want to load key this way …

  6. linux - Why use Python's os module methods instead of executing …

    Feb 18, 2015 · I am trying to understand what is the motivation behind using Python's library functions for executing OS-specific tasks such as creating files/directories, changing file …

  7. How do I move a file in Python? - Stack Overflow

    for those of you familiar with gnu-coreutils' mv command, python's shutil.move has one edge case where shutil.move function differs. Go here for full write up. In a nutshell, Python's shutil.move …

  8. python - Using the OS library for volumes and external locations …

    Sep 29, 2023 · 1 I have several processes in Databricks using the OS library, for creating txt files, checking directories, etc. With the arrival of Volumes and the use of external locations "abfss", …

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

    133 Python 3.4 introduced the pathlib module into the standard library, which provides an object oriented approach to handle filesystem paths. The is_dir() and exists() methods of a Path …

  10. How do I execute a program or call a system command?

    Even the documentation for os.system recommends using subprocess instead. On Python 3.4 and earlier, use subprocess.call instead of .run: