Код: Выделить всё
from textwrap import dedent
block_a = """\
Line one
Line two"""
block_b = """\
Line four
Line five"""
blocks = f"""\
{block_a}
Line three
{block_b}"""
print(dedent(blocks))
Код: Выделить всё
Line one
Line two
Line three
Line four
Line five
Код: Выделить всё
Line one
Line two
Line three
Line four
Line five
Код: Выделить всё
blocks = f"""\
{dedent(block_a)}
Line three
{dedent(block_b)}"""
print(dedent(blocks))
Код: Выделить всё
Line one
Line two
Line three
Line four
Line five
В приведенном выше случае перед общим отступом я хочу:
Код: Выделить всё
Line one
Line two
Line three
Line four
Line five
Код: Выделить всё
blocks = f"""\
{dedent(block_a)}
Line three
{dedent(block_b)}"""
Код: Выделить всё
Line one
Line two
Line three
Line four
Line five
< /code>
У меня есть обходной путь, используя строку формата вместо F-String, < /p>
blocks = """\
{}
Line three
{}"""
print(dedent(blocks).format(dedent(block_a), dedent(block_b)))
Подробнее здесь: https://stackoverflow.com/questions/793 ... -variables