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

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

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

    Dec 16, 2014 · 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.

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

    Jul 19, 2012 · In this case, it feels especially bad because iterators relate in a quasi-functional, value-based way to the contents of a file, but managing file handles is a completely separate task. …

  6. python - Correct way to write line to file? - Stack Overflow

    May 28, 2011 · When the file is opened in text mode (the default), it is translated automatically to the correct line ending for the current platform. Writing "\r\n" would produce "\r\r\n" which is wrong.

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

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

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

    315 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. python - How to read a large file - line by line? - Stack Overflow

    Nov. 2022 Edit: A related question that was asked 8 months after this question has many useful answers and comments. To get a deeper understanding of python logic, do also read this related question …