CKTIS / Python
str.join
Unisce le stringhe di un iterabile inserendo il separatore ricevente fra le posizioni.
Versione: Python 3.14; repository image, production runtime not attested
Sintassi
separator.join(iterable_of_strings)Unisce le stringhe di un iterabile inserendo il separatore ricevente fra le posizioni.
L’elemento vuoto fra a e c produce due separatori consecutivi.
Un ingresso vuoto dà la stringa vuota; un elemento che non è str solleva TypeError.
assert ",".join(iter(["", "x", ""])) == ",x,"
Esempi
print("|".join(["a", "", "c"]))
print(repr("|".join([])))
Risultato
a||c ''
Un ingresso vuoto dà la stringa vuota; un elemento che non è str solleva TypeError.