How to use the split () function in python
This article mainly introduces how to use the split () function in python, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.
Str.split ('')
1. To divide by a character, such as'.'
> s = ('www.google.com') > print (s) www.google.com > s.split ('.') ['www',' google', 'com']
two。 It is divided by a certain character and divided n times. If you press'.' Split once; the number of times the maxsplit bit is cut
> s = 'www.google.com' > swatches www.google.com' > s.split ('., maxsplit=1) ['www',' google.com']
3. Split by a string. For example:'| |'
> s = 'WinXP | | Win7 | | Win8 | | Win8.1' > s'WinXP | | Win7 | | Win8 | | Win8.1' > s.split (' | |') ['WinXP',' Win7', 'Win8',' Win8.1'] > > python has some common libraries commonly used by python: 1.requesutsshare, 2.scrapyfive3.pillowtellance4.twistedtransfer5.numpyteran6.matplotlibans7.pygamatransfer8.ipyhton, etc.
Thank you for reading this article carefully. I hope the article "how to use the split () function in python" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!