Átomo
23Sw
Texto e regex · Python

startswith / in

Abrir na tabela

Definição

Testam prefixo, sufixo e presença de um trecho no texto.

Exemplos

1. Prefixo e sufixo
if name.startswith("stg_") and path.endswith(".parquet"):
    ...
2. Trecho contido
if "timeout" in message.lower():
    retry()
3. Filtrar uma lista
sales_files = [f for f in files if f.startswith("sales_")]

No mesmo grupo