我是python的新手,我编写了一个脚本,将进入的字符串日期转换为datetime格式化.我的问题是无法将datetime对象转换回字符串进行操作.我有一个约会,例如2011-08-10 14:50:10我需要T在日期和时间之间添加一个日期和Z结尾.不幸的是我使用python 2.3作为我的应用程序将只接受.
我的代码如下:
fromValue= ''
fromValue = document.Get(self._generic3)
fromValue = fromValue[:fromValue.rindex(" ")]
fromValue = datetime.datetime.fromtimestamp(time.mktime(time.strptime(fromValue,"%a, %d %b %Y %H:%M:%S")))
Run Code Online (Sandbox Code Playgroud)