About 564,000 results
Open links in new tab
  1. open() in Python does not create a file if it doesn't exist

    Jun 3, 2010 · What is the best way to open a file as read/write if it exists, or if it does not, then create it and open it as read/write? From what I read, file = open ('myfile.dat', 'rw') should do …

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

    401 Python allows putting multiple open() statements in a single with. You comma-separate them. Your code would then be: def filter(txt, oldfile, newfile): '''\ Read a list of names from a file line …

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

  4. python - What encoding does open () use by default? - Stack …

    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 …

  5. python - How to open local file on Jupyter? - Stack Overflow

    It's a pity there is no possibility to right-click any folder in jupyter's "explorer view" and get a menu option to open the folder in the true os file explorer. This leads to convoluted tricks for files and …

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

    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: from pathlib import Path

  7. How can I make one python file run another? - Stack Overflow

    How can I make one python file to run another? For example I have two .py files. I want one file to be run, and then have it run the other .py file.

  8. python - How to replace/overwrite file contents instead of …

    When you say "replace the old content that's in the file with the new content", you need to read in and transform the current contents data = file.read(). You don't mean "blindly overwrite it …

  9. python - open () gives FileNotFoundError / IOError: ' [Errno 2] No …

    For example, if you want to access file.txt which is inside the Document, try opening the IDE from Document by right clicking in the directory and clicking "Open with "

  10. 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: …