About 385,000 results
Open links in new tab
  1. 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 start …

  2. 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.

  3. 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 you have to …

  4. linux - Why use Python's os module methods instead of executing shell ...

    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 attributes, etc. instead …

  5. How to identify which OS Python is running on - Stack Overflow

    The above Python program will show you the output of the most commonly used built-in functions, already provided by os, sys, platform, site. So the best way to get only the essential code is looking …

  6. python - How do I remove/delete/replace a folder that is not empty ...

    Essentially it's using Python's subprocess module to run the bash script $ rm -rf '/path/to/your/dir as if you were using the terminal to accomplish the same task.

  7. How can I access environment variables in Python?

    I haven’t set it (PYTHONPATH) before; what I am doing just go with command prompt and type CMD anywhere (since python.exe is in my shell PATH). If I try to access Window ENVIRONMENT …

  8. Open document with default OS application in Python, both in …

    104 open and start are command-interpreter things for Mac OS/X and Windows respectively, to do this. To call them from Python, you can either use subprocess module or os.system(). Here are …

  9. shutil - How do I copy an entire directory of files into an existing ...

    else: if not os.path.exists(d) or os.stat(s).st_mtime - os.stat(d).st_mtime > 1: shutil.copy2(s, d) In my above implementation Creating the output directory if not already exists Doing the copy directory by …

  10. python - List files ONLY in the current directory - Stack Overflow

    Aug 15, 2012 · In Python, I only want to list all the files in the current directory ONLY. I do not want files listed from any sub directory or parent. There do seem to be similar solutions out there, but they d...