You can split a string by using split()
. The syntax is as follows…
stringtosplit.split('whattosplitat')
To split your example at every comma and space, it would be:
s="str1, str2, str3, str4"
s.split(', ')
More Related Contents:
- Split a string by a delimiter in python
- Splitting on last delimiter in Python string?
- How to split strings inside a list by whitespace characters
- Convert string to list. Python [string.split() acting weird]
- Convert list of strings to dictionary
- Unable to use convert strings into integers for a for loop
- How do I concatenate items in a list to a single string?
- Create nice column output in python
- How do I check if there are duplicates in a flat list?
- Splitting a string into words and punctuation
- String to list in Python
- How can I convert each item in the list to string, for the purpose of joining them? [duplicate]
- Removing a list of characters in string
- Product code looks like abcd2343, how to split by letters and numbers?
- Get last “column” after .str.split() operation on column in pandas DataFrame
- case-insensitive list sorting, without lowercasing the result?
- How does the max() function work on list of strings in python?
- str.startswith with a list of strings to test for
- Split a string only by first space in python
- How would I get everything before a : in a string Python
- How to transform string of space-separated key,value pairs of unique words into a dict
- Why python’s list slicing doesn’t produce index out of bound error? [duplicate]
- Converting a string that represents a list, into an actual list object
- Python: find closest string (from a list) to another string
- How to concatenate (join) items in a list to a single string
- How to convert a string with comma-delimited items to a list in Python?
- How to split a Python string on new line characters [duplicate]
- Column of lists, convert list to string as a new column
- How can I convert string values from a dictionary, into int/float datatypes?
- Splitting a math expression string into tokens in Python