Answers for "python splitlines"

3

python split lines

>>> text = """Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia,
molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum
numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium
optio, eaque rerum! Provident similique accusantium nemo autem."""

# the str.splitlines() method is basically just str.split("n").
>>> text.splitlines()
[
	'Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia,',
	'molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum',
	'numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium',
	'optio, eaque rerum! Provident similique accusantium nemo autem.'
]
Posted by: Guest on March-01-2021
24

split string python

file='/home/folder/subfolder/my_file.txt'
file_name=file.split('/')[-1].split('.')[0]
Posted by: Guest on April-01-2020

Python Answers by Framework

Browse Popular Code Answers by Language