“Python Split en el índice” Código de respuesta

cómo dividir la cadena por lista de índices python

In [42]: s = "Hello there!"

In [43]: [s[v1:v2] for v1, v2 in zip([0]+l, l+[None])]
Out[43]: ['He', 'llo ', 'the', 're!']
Ava

Python Split en el índice

>>> list1 = ['a','b','c','d','e','f','g','h', 'i', 'j', 'k', 'l']
>>> print list1[:5]
['a', 'b', 'c', 'd', 'e']
>>> print list1[-7:]
['f', 'g', 'h', 'i', 'j', 'k', 'l']
# Note how you can slice either positively or negatively.
# When you use a negative number, it means we slice from right to left.
Ugliest Unicorn

Respuestas similares a “Python Split en el índice”

Preguntas similares a “Python Split en el índice”

Más respuestas relacionadas con “Python Split en el índice” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código