Programador Leigo
⚡ 60 segundos strings

5 métodos de string que todo iniciante precisa

strip, split, join, replace e endswith resolvem 90% dos problemas com texto em Python.

str_metodos.py
texto = '  Ola, Python!  '

print(texto.strip())         # sem espacos
print(texto.split(','))      # divide
print('-'.join(['a','b']))   # junta
print(texto.replace('Ola','Oi'))
print('arquivo.py'.endswith('.py'))  # True

Compartilhar