How to Split a String with Python
Splitting a string in Python is really easy.
You simply take a string
and apply the split()
method.
"Your String".split()
See some examples of the Python Split String method:
A Python Split String – Example
Python Split String – Syntax
|
|
Parameter Values
Parameter | Description |
separator | Optional – What to split the string on. The default is the whitespace character |
maxsplit | Optional – How many splits to perform. The default is -1, meaning “no limit” |
Some examples for Python Split String
Use a comma (,
) as the separator:
Use a pipe (|
) as the separator: