Latest web development tutorials

Python3 splitlines () method

Python3 string Python3 string


description

Python splitlines () are separated by rows, each row returned as a list of elements contained, only if specified slice num num rows.

grammar

splitlines () method syntax:

str.splitlines( num=string.count('\n'))

parameter

  • num - the number of swath.

return value

It returns a list of rows as elements contain.

Examples

The following example shows splitlines () function to use:

#!/usr/bin/python3

str = "this is \nstring example....\nwow!!!"
print (str.splitlines( ))

Examples of the above output results are as follows:

['this is ', 'string example....', 'wow!!!']

Python3 string Python3 string