简体   繁体   中英

Add custom text message after break line

The below code snippet sends email with status. If I want to add another line break with text as Sent from Scheduler. What could be the possible way ?

def send_email(status,message):
    date = str(datetime.now().date())[-5:].replace('-', '/')
    yag.send(to=TO_EMAIL,subject="{} Rebuild Code: {}".format(date, status),contents=message)
    logging.info("Mail Sent!")

Thanks!

Please try this updated code.

Update :

def send_email(status,message):
    date = str(datetime.now().date())[-5:].replace('-', '/')
    message = "{}\n{}".format(message, 'Sent from Scheduler'
    yag.send(to=TO_EMAIL,subject="{} Rebuild Code: {}".format(date, status),contents=message))
    logging.info("Mail Sent!")

Here, instead of just returning the message, it can be updated as "{}\\n{}".format(message, 'Sent from Scheduler') \\n is the single line break. If you want multiple line breaks you can use \\n\\n .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM