About 986,000 results
Open links in new tab
  1. python - How do I split a multi-line string into multiple lines ...

    inputString.splitlines() Will give you a list with each item, the splitlines() method is designed to split each line into a list element.

  2. How to split a Python string on new line characters

    216 Splitting line in Python: Have you tried using str.splitlines() method?: Python 2.X documentation here. Python 3.X documentation here. From the docs: str.splitlines([keepends]) …

  3. Split string using a newline delimiter with Python

    If your string ends in a \n, splitlines() will ignore it while split("\n") will have an additional empty string "" at the end of the result.

  4. python - Splitting a string separated by "\r\n" into a list of lines ...

    Jul 27, 2010 · Use the splitlines method on the string. From the docs: str.splitlines ( [keepends]) Return a list of the lines in the string, breaking at line boundaries. Line breaks are not included …

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

  6. python - Iterate over the lines of a string - Stack Overflow

    lineiterator = iter(foo.splitlines()) Is there a more direct way of doing this? In this scenario the string has to traversed once for the splitting, and then again by the parser. It doesn't matter in …

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

  8. readfile - difference between readlines () and split () [python ...

    imagine we have a file = open ("filetext.txt", 'r') what is the difference between the split () method and the readlines () method It seems that both split each line and put it as a string in a list...

  9. Splitting lines from a text file in Python 3 - Stack Overflow

    Splitting lines from a text file in Python 3 Asked 9 years, 11 months ago Modified 1 year, 2 months ago Viewed 44k times

  10. What's a quick one-liner to remove empty lines from a python …

    I have some code in a python string that contains extraneous empty lines. I would like to remove all empty lines from the string. What's the most pythonic way to do this? Note: I'm not looking f...