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

    It's not fully Python, but it gets it done. The reason I included the pathlib.Path example is because in my experience it's very useful when dealing with many paths that change. The extra steps of importing …

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

    60 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 of remove …

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

    Apr 15, 2021 · 110 pathlib is the more modern way since Python 3.4. The documentation for pathlib says that "For low-level path manipulation on strings, you can also use the os.path module." It …

  4. How to rename a file using Python - Stack Overflow

    Furthermore, the pathlib library is introduced in python 3.4 so sharing the answer here also provides exposure for a solid module to showcase its versatility and usage for more complicated …

  5. python - How to check whether a directory is a sub directory of …

    Sep 28, 2010 · Python 3.4 added the pathlib module which can perform these kind of path operations in a more sophisticated way, optionally without referencing the underlying OS. jme has described in …

  6. python - Get directories only with glob pattern using pathlib - Stack ...

    Sep 9, 2022 · 6 I want to use pathlib.glob() to find directories with a specific name pattern (*data) in the current working dir. I don't want to explicitly check via .isdir() or something else. Input data This is the …

  7. How can I replace (or strip) an extension from a filename in Python?

    Longer Answer: The best way to do this will depend on your version of python and how many extensions you need to handle. That said, I'm surprised nobody has mentioned pathlib's with_name. I'm also …

  8. python - Use pathlib for S3 paths - Stack Overflow

    Explains how to use Python's pathlib library for handling S3 paths effectively.

  9. python - How do I check whether a file exists without exceptions ...

    The pathlib module was introduced in Python 3.4, so you need to have Python 3.4+. This library makes your life much easier while working with files and folders, and it is pretty to use.

  10. python - How do I append a string to a Path? - Stack Overflow

    Jan 10, 2018 · from pathlib import Path Desktop = Path('Desktop') SubDeskTop = Path.joinpath(Desktop, "subdir") the joinpath() function will append the second parameter to the first …