繁体   English   中英

在换行符后添加自定义短信

[英]Add custom text message after break line

以下代码段发送带有状态的电子邮件。 如果我想添加另一个换行符,并使用计划程序发送的文本。 可能的方法是什么?

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!")

谢谢!

请尝试此更新的代码。

更新

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!")

在这里,不仅可以返回消息,还可以将其更新为"{}\\n{}".format(message, 'Sent from Scheduler') \\n是单个换行符。 如果要多个换行符,可以使用\\n\\n

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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