About 193,000 results
Open links in new tab
  1. 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? example: …

  2. How to open a file using the open with statement - Stack Overflow

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

  3. 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:

  4. python - What is the difference between rb and r+b modes in file ...

    Apr 1, 2013 · Python on Windows makes a distinction between text and binary files; the end-of-line characters in text files are automatically altered slightly when data is read or written.

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

    Aug 24, 2011 · Suppose my python code is executed a directory called main and the application needs to access main/2091/data.txt. how should I use open (location)? what should the …

  6. Open File in Another Directory (Python) - Stack Overflow

    Sep 9, 2015 · If you have Python 3.4 or above, the pathlib library comes with the default distribution. To use it, you just pass a path or filename into a new Path () object using forward …

  7. python - If you're opening a file using the 'with' statement, do you ...

    Jan 22, 2014 · In fact, several code samples in the official docs neglect closing a file that has been opened only for read access. When writing a file or when using the "read plus" mode like …

  8. open() in Python does not create a file if it doesn't exist

    Jun 3, 2010 · The file pointer is at the end of the file if the file exists. The file opens in the append mode. If the file does not exist, it creates a new file for reading and writing. - Python file modes …

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

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

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

    Jul 11, 2011 · Is there a way to open a file for both reading and writing? As a workaround, I open the file for writing, close it, then open it again for reading. But is there a way to open a file for …