私はOutlookのcreationTime形式を変更したいと思います。python:どのようにOutlookを変更するには、作成時間形式を取得する?
for message in sub.Items:
subject = message.subject
body = message.body
sendTime = message.CreationTime
私はmessage.CreationTime
を使用するためのメッセージcreationTime
を取得します。 sendTime
を印刷すると、結果は04/15/16 17:22:29になります。 したがって、私はstrftime
を使用して日付形式を変更しましたが、動作しません。
ソースコードにそのようなライブラリをインポートしました。
import win32com.client
from datetime import datetime, date, time
import string
import pymysql
しかし、エラーが発生しました:
Traceback (most recent call last):
File "D:\20_log\outlook\outlook.py", line 164, in <module> main()
File "D:\20_log\outlook\outlook.py", line 161, in main get_outlook_message()
File "D:\20_log\outlook\outlook.py", line 56, in get_outlook_message
sendTime.strftime('%H:%M:%S')
AttributeError: strftime
にはどうすれば見通しcreationTime
形式を変更できますか?
印刷 'タイプ(SENDTIME)'と 'message.CreationTime'は、あなたがそれを変換するために何をすべきか判断するのに役立つべきである値の種類を見る(それはdoesnの'datatime'オブジェクトのように見えます)。 – martineau
返信いただきありがとうございます。タイプ(sendTime)を印刷したときの結果はです。そして私は値を印刷しました。その結果は04/15/16 17:22:29です。私はこのようなsendTime形式を印刷したい2016-04-15 17:22:29。 –
Bethlee
Strange ...それは 'strftime()'メソッドを持つべきです。モジュールレベルの関数 'time.strftime( '%H:%M:%S'、sendTime)を使ってみてください。 – martineau