Как распечатать текущую дату в myTeamsMessage.название API pymsteams

#python-3.x #microsoft-teams

Вопрос:

Я пытаюсь отправить автоматическое сообщение через API Python «pymsteams», но я застрял в одном месте. Я хочу установить текущую дату в заголовке моего сообщения автоматизированных команд, но не могу этого сделать. Кто-нибудь может мне здесь помочь. Я поделился своим кодом для большей ясности. Спасибо!!

 import pymsteams
from datetime import date
 
# You must create the connectorcard object with the Microsoft Webhook URL
myTeamsMessage = pymsteams.connectorcard("<<Webhook url passing here>>")

today = date.today()
d1 = today.strftime("%d/%m/%Y")
# Add text to the message.
myTeamsMessage.title("d1- Americas Virtual Stand-up")
myTeamsMessage.text("this is my text")

# send the message.
myTeamsMessage.send()
 

Ответ №1:

попробуйте использовать эти только что использованные f-строки Python3

 import pymsteams
from datetime import date
 
# You must create the connectorcard object with the Microsoft Webhook URL
myTeamsMessage = pymsteams.connectorcard("<<Webhook url passing here>>")

today = date.today()
d1 = today.strftime("%d/%m/%Y")
# or user this formate
# d1 = today.strftime("%d-%m-%Y")
# Add text to the message.
myTeamsMessage.title(f"{d1} - Americas Virtual Stand-up")
myTeamsMessage.text("this is my text")

# send the message.
myTeamsMessage.send()