我正在将 php 代码迁移到 Python 中并遇到了 datetime。我的代码:
date_raw = datetime.datetime.strptime(data["Campaign_Start_Date"], '%Y-%m-%d')
date_new = date_raw.strftime("%Y-%m-%d"+"T"+"%H:%M:%S GMT")
print(date_new)
# 2020-09-14T00:00:00 GMT
我想要的输出是:2020-09-14T00:00:00-04:00所以我需要将 GMT 附加到字符串的末尾,但找不到返回正确格式的方法。