2016年9月23日金曜日

python年月日stringからDateを抽出

#!/usr/bin/python
# -*- coding:utf-8 -*-
import sys
import datetime

strdate = "2016年9月23日(金)"

locale.setlocale(locale.LC_ALL, "")
print(locale.getlocale())

#出力
d = datetime.datetime.today()
print (d.strftime("%Y年%m月%d日(%a)") )
print (d.strftime("%p") )
print (d.strftime("%x %X") )

#抽出
print(datetime.datetime.strptime(strdate, "%Y年%B%d日(%a)"))

0 件のコメント: