About 57 results
Open links in new tab
  1. 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...

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

    Oct 3, 2025 · 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 …

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

    102 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:

  4. python - How to open a file for both reading and writing ... - Stack ...

    Jul 11, 2011 · And: f.write (string) writes the contents of string to the file, returning None. Also if you open Python tutorial about reading and writing files you will find that: 'r+' opens the file for both …

  5. How can I open multiple files using "with open" in Python?

    Since Python 3.3, you can use the class ExitStack from the contextlib module to safely open an arbitrary number of files. It can manage a dynamic number of context-aware objects, which means that it will …

  6. python - What encoding does open () use by default? - Stack Overflow

    The default UTF-8 encoding of Python 3 only extends to conversions between bytes and str types. open() instead chooses an appropriate default encoding based on the environment: encoding is the …

  7. Open file in a relative location in Python - Stack Overflow

    Aug 24, 2011 · Open file in a relative location in Python [duplicate] Asked 14 years, 5 months ago Modified 2 years, 5 months ago Viewed 883k times

  8. function - How to Open a file through python - Stack Overflow

    Oct 22, 2013 · I am very new to programming and the python language. I know how to open a file in python, but the question is how can I open the file as a parameter of a function?

  9. What does 'wb' mean in this code, using Python? - Stack Overflow

    Apr 19, 2010 · Also you should consider using open instead of file. file was deprecated in Python 2 (couldn't find which version) and has been removed in py3k. (thanks Scott) See this question for …

  10. Método open() en Python - Stack Overflow en español

    Aug 19, 2020 · tengo un pequeño problema con open(). Como saben, podemos colocar argumentos que indican si abrimos un archivo externo en modo escritura, lectura u otro: from io import open …