Python

Python Menu

Python

Python String splitlines() - Definition, Syntax, Parameters, Examples

Definition

The splitlines() method splits a string into a list. The splitting is done at line breaks.

Syntax

string.splitlines(keeplinebreaks)

Parameters

Parameter Description
keeplinebreaks Optional. Specifies if the line breaks should be included (True), or not (False). Default value is False

Examples:

testStr = "Welcome to the Python tutorials. \nPython is a scripting language." result = testStr.splitlines() print(result)
# keeping the line breaks testStr = "Welcome to the Python tutorials. \nPython is a scripting language." result = testStr.splitlines(True) print(result)

Introduction

Python Basics

Python Advance

Data Science Python Tutorials

Python Functions and Methods