Programador Leigo
⚡ 60 segundos strings

Strings de múltiplas linhas em Python

Use aspas triplas para criar strings longas sem concatenação. Funciona com f-strings também!

multiline.py
mensagem = '''
Ola, mundo!
Isso e uma string
de varias linhas.
'''.strip()

print(mensagem)

# Com f-string
nome = 'Python'
html = f'''
<h1>Bem-vindo ao {nome}</h1>
'''.strip()
print(html)

Compartilhar