[Python] Add a new line to a string in Python for email message (not print statement)

Discussão em 'Python' iniciado por Stack, Outubro 23, 2024.

  1. Stack

    Stack Membro Participativo

    I need to send an smtp message, which is created dynamically in code. But inserting new line character "\n" does not work because I am not using the "print" function.

    I searched for an existing question but did not find one. I found this post but all responses refer to print, and anyway the content is disputed.

    x = "line one\n line two"

    x
    Out[105]: 'line one\n line two'


    How can I create a string such that the string value (not using print or writing to a file) is like this?

    line one
    line two

    Continue reading...

Compartilhe esta Página