Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the split () function in python

Shulou Source: shulou.com Published: 2022-06-01 02:56:05 09月22日 Update

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!

Tags: Articles characters functions commonly used values interests parameters at the same time strings more friends times knowledge editing industry information information channels channels references learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB MySQL macOS Shulou Information OPPO Reno