About 826,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 …

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

  3. Unicode (UTF-8) reading and writing to files in Python

    I'm having some brain failure in understanding reading and writing text to a file (Python 2.4).

  4. python - Replace string within file contents - Stack Overflow

    Replacing instances of a character in a string (17 answers) How to search and replace text in a file (23 answers) How to read a large file - line by line? (12 answers) Writing a list to a file with …

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

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

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

    ABC DEF How can I read the file into a single-line string without newlines, in this case creating a string 'ABCDEF'? For reading the file into a list of lines, but removing the trailing newline …

  8. How to replace/overwrite file contents instead of appending?

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

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

    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 …