About 15,400,000 results
Open links in new tab
  1. python - How do I check whether a file exists without exceptions ...

    How do I check whether a file exists, using Python, without using a try statement? Now available since Python 3.4, import and instantiate a Path object with the file name, and check the is_file method …

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

    101 On Python 3.4, the pathlib module was added, and the following code will reliably open a file in the same directory as the current script:

  3. python - Difference between modes a, a+, w, w+, and r+ in built-in …

    In Python's built-in open function, what is the difference between the modes w, a, w+, a+, and r+? The documentation implies that these all allow writing to the file, and says that they open the fi...

  4. 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?

  5. python - How to search and replace text in a file - Stack Overflow

    How do I search and replace text in a file using Python 3? Here is my code:

  6. python - Importing files from different folder - Stack Overflow

    I have this folder structure: application ├── app │ └── folder │ └── file.py └── app2 └── some_folder └── some_file.py How can I import a function from file.py, from within som...

  7. 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 os.getcwd …

  8. python - How to open a file using the open with statement - Stack …

    I'm looking at how to do file input and output in Python. I've written the following code to read a list of names (one per line) from a file into another file while checking a name against the name...

  9. Visual Studio Code: run Python file with arguments

    Apr 30, 2017 · Is there an easy way to run a Python file inside Visual Studio Code with arguments? I know I can add a custom configuration in the launch.json file with the args keyword. However, it is …

  10. How should I read a file line-by-line in Python? - Stack Overflow

    Jul 19, 2012 · If iteration closed the file, I wouldn't be able to do that. So keeping iteration and resource management separate makes it easier to compose chunks of code into a larger, working Python …