About 1,120,000 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 …

    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 files for …

  3. python - How can I open a URL? - Stack Overflow

    45 import webbrowser webbrowser.open(url, new=0, autoraise=True) Display url using the default browser. If new is 0, the url is opened in the same browser window if possible. If new is 1, a new …

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

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

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

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

    39 Most likely, the problem is that you're using a relative file path to open the file, but the current working directory isn't set to what you think it is. It's a common misconception that relative paths are relative …

  9. python - How do I append to a file? - Stack Overflow

    Jan 16, 2011 · When you open with "a" mode, the write position will always be at the end of the file (an append). You can open with "a+" to allow reading, seek backwards and read (but all writes will still …

  10. 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 this, right?...