如何Asia/Calcutta在 Flutter/Dart 中获取当前时区名称?
DateTime.now().timeZoneName获取 String IST。
DateTime.now().timeZoneOffset获取 Duration 5:30:00.000000。
Intl.DateTimeFormat().resolvedOptions().timeZoneAsia/Calcutta在 JavaScript 中给出所需的结果。
任何帮助表示赞赏。谢谢。
我已根据代码的要求创建了一个 API 密钥并将其添加到环境中。
以下是我正在使用的代码,并已按照此处提供的步骤进行操作。
# using SendGrid's Python Library
# https://github.com/sendgrid/sendgrid-python
import os
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail
message = Mail(
from_email='from_email@example.com',
to_emails='to@example.com',
subject='Sending with Twilio SendGrid is Fun',
html_content='<strong>and easy to do anywhere, even with Python</strong>')
try:
sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
response = sg.send(message)
print(response.status_code)
print(response.body)
print(response.headers)
except Exception as e:
print(e.message)
Run Code Online (Sandbox Code Playgroud)
它抛出这个错误:
Traceback (most recent call last):
File "sendgrid_email.py", line 18, in <module>
print(e.message)
AttributeError: "ForbiddenError" object has no attribute "message"
Run Code Online (Sandbox Code Playgroud)
在打印异常时,它显示 pylint …