Answers for "python split example"

12

python split

>>> '1,2,3'.split(',')
['1', '2', '3']
>>> '1,2,3'.split(',', maxsplit=1)
['1', '2,3']
>>> '1,2,,3,'.split(',')
['1', '2', '', '3', '']
Posted by: Guest on November-18-2020
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
2

python split string

txt = "hello, my name is Peter, I am 26 years old"

x = txt.split(", ")
Posted by: Guest on July-21-2021

Python Answers by Framework

Browse Popular Code Answers by Language