About 180,000 results
Open links in new tab
  1. 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

  2. python - How to read a file line-by-line into a list? - Stack Overflow

    How do I read every line of a file in Python and store each line as an element in a list? I want to read the file line by line and append each line to the end of the list.

  3. python - open read and close a file in 1 line of code - Stack Overflow

    The shortest, built-in way to achieve opening, reading, and closing a file in Python is using 2 logical lines whether it's condensed down to 1 line or not. So I don't see this answer to be effectively any different …

  4. python - How to read a file without newlines? - Stack Overflow

    Python automatically handles universal newlines, thus .split('\n') will split correctly, independently of the newline convention. It would matter if you read the file in binary mode.In that case splitlines() handles …

  5. python - How to read pickle file? - Stack Overflow

    The following is an example of how you might write and read a pickle file. Note that if you keep appending pickle data to the file, you will need to continue reading from the file until you find what …

  6. Easiest way to ignore blank lines when reading a file in Python

    Easiest way to ignore blank lines when reading a file in Python Asked 14 years, 10 months ago Modified 4 years, 5 months ago Viewed 191k times

  7. python - Reading JSON from a file - Stack Overflow

    If you are reading the data from the Internet instead, the same techniques can generally be used with the response you get from your HTTP API (it will be a file-like object); however, it is heavily …

  8. python - Difference between modes a, a+, w, w+, and r+ in built-in …

    On Windows, b appended to the mode opens the file in binary mode, so there are also modes like rb, wb, and r+b. Python on Windows makes a distinction between text and binary files; the end-of-line …

  9. python - How to read a Parquet file into Pandas DataFrame ... - Stack ...

    How to read a modestly sized Parquet data-set into an in-memory Pandas DataFrame without setting up a cluster computing infrastructure such as Hadoop or Spark? This is only a moderate amount of dat...

  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 …