Python tip 25: split and partition string methods

Pubblicato il: 20 marzo 2023
sul canale di: learnbyexample
240
4

The `split()` method splits a string based on the given substring and returns a `list`. By default, whitespace is used for splitting and empty elements are discarded. The `maxsplit` argument allows you to restrict the number of times the input string should be split. Use `rsplit()` if you want to split from right to left.

The `partition()` method will give a `tuple` of three elements — portion before the leftmost match, the separator itself and the portion after the split. You can use `rpartition()` to match the rightmost occurrence of the separator.


This video is based on content from my "100 Page Python Intro" ebook: https://github.com/learnbyexample/100...


In questa pagina del sito puoi guardare il video online Python tip 25: split and partition string methods della durata di ore minuti seconda in buona qualità , che l'utente ha caricato learnbyexample 20 marzo 2023, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 240 volte e gli è piaciuto 4 spettatori. Buona visione!