

You can note that separator is missed in the ouput list. Print "Python2 Python3 Python Numpy".split(' ') print "Python2, Python3, Python, Numpy".split(',') In the example below the string is split by comma and semi colon (which can be used for CSV files. Python split string by comma or any other character use the same method split() with parameter - comma, dot etc. Print "Python2, Python3, Python, Numpy".split()

Print "Python2 Python3 Python Numpy".split()

with parameter - comma, dot etc - see next section.without parameter - then space is used as separator.If you want to split any string into a list (of substrings) you can use simply the method split(). IntelliJ/P圜harm performance and beauty tips.Python useful tips and reference project.You could be interested in these articles about python: Split string by consecutive separators(regex).Python split string by first occurrence.Split string dictionary into lists (map).Split multi-line string into a list (per line).There is an example for using regular expression for spliting strings:
#Python split how to#
You can see the using of a separator, dictionaries, split only on first separator or how to treat consecutive separators. In this post you can find useful information for beginers and advanced how to split strings into lists.
