How python splits strings
Editor to share with you python how to split strings, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Split string
When working with strings, you usually separate the strings into a list of words. In this case, the delimiter of the split () function can be used, and the maximum delimiter is optional. The related functions are the rsplit () function, which is similar to the split () function, except that it is split from the right side when set up to meet the maximum segmentation requirements.
> sentence = 'this is, apython, tutorial, about, idioms.' > sentence.split (',') ['this is',' apython', 'tutorial',' about', 'idioms.'] > sentence.split (',', 2) ['this is',' apython', 'tutorial, about, idioms.'] > sentence.rsplit (',') ['this is',' apython', 'tutorial',' about' 'idioms.'] > sentence.rsplit (',', 2) ['this is, a python, tutorial',' about', 'idioms.'] The above is all the content of the article "how to split strings in python". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!