Answers for "python split by comma"

1

split a string by comma python

# We can use the split() function and put a "," in the parameter 
# It'll return a list with the string split up by commas.
txt = "hello, my name is Peter, I am 26 years old"

x = txt.split(",")
print(x)

# You can also do this
for thing in x:
  print(thing)
Posted by: Guest on March-16-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
0

how to split string with comma in python

# We can use the split() function and put a "," in the parameter 
# It'll return a list with the string split up by commas.
txt = "hello, my name is Peter, I am 26 years old"

x = txt.split(",")
print(x)
Posted by: Guest on June-15-2021
0

split a string by comma in python

str = 'apple,orange,grape'

#split string by ,
chunks = str.split(',')

print(chunks)
Posted by: Guest on May-12-2021

Python Answers by Framework

Browse Popular Code Answers by Language