Python String splitlines() Method
Python splitlines() method splits the string based on the lines. It breaks the string at line boundaries and returns a list of splitted strings. Line breakers can be a new line (\n), carriage return (\r) etc. A table of line breakers are given below which split the string.
This method splits on the given line boundaries.
keepends: It is a boolean value which can be either True or False. It is optional.
It returns a comma separated list of lines.
Let's see some examples of splitlines() method to understand it's functionality.
Python String splitlines() Method Example 1
Java is a programming language ['Java is a programming language'] ['Java ', ' is a programming ', ' language']
Python String splitlines() Method Example 2
Passing True to the method which causes to include line breakers into the list of string. See the example below.
['Java \n', ' is a programming \r', ' language']
Python String splitlines() Method Example 3
['Java ', ' is a programming ', ' language for ', ' software development'] Java is a programming language for software development
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week