About 583,000 results
Open links in new tab
  1. How do I open a text file in Python? - Stack Overflow

    Oct 18, 2016 · Currently I am trying to open a text file called "temperature.txt" i have saved on my desktop using file handler, however for some reason i cannot get it to work. Could anyone tell me …

  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 names in the file …

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

  4. How do I print the content of a .txt file in Python?

    Aug 15, 2013 · Anyways, I'm working on a piece of code that will open a file, print out the contents on the screen, ask you if you want to edit/delete/etc the contents, do it, and then re-print out the results …

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

    Jul 19, 2012 · On a technical level, there are some things you may want to do with a file handle in Python which would not work as well if iteration closed the file handle. For example, suppose I need …

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

    Jan 16, 2011 · On some operating systems, opening the file with 'a' guarantees that all your following writes will be appended atomically to the end of the file (even as the file grows by other writes). A few …

  7. python - Given a URL to a text file, what is the simplest way to read ...

    186 In Python, when given the URL for a text file, what is the simplest way to access the contents off the text file and print the contents of the file out locally line-by-line without saving a local copy of the text …

  8. How to open and edit an existing file in Python? - Stack Overflow

    Dec 16, 2014 · 3 The open() built-in Python method (doc) uses normally two arguments: the file path and the mode. You have three principal modes (the most used): r, w and a.

  9. python - How can I read a text file into a string variable and strip ...

    314 In Python 3.5 or later, using pathlib you can copy text file contents into a variable and close the file in one line:

  10. Easiest way to read/write a file's content in Python

    In Ruby you can read from a file using s = File.read (filename). The shortest and clearest I know in Python is with open (filename) as f: s = f.read () Is there any other way to do it that makes it