20190708 time和datetime 常用模塊使用

from datetime import datetime
datetime.strptime(b,'%Y年%m月%d日')#將字符串轉化爲時間格式格式

import time
time.strptime(b,'%Y年%m月%d日')#將字符串轉化爲分段時間戳格式
now_date = datetime.now().strftime('%Y-%m-%d') # 當前時間格式轉化爲字符串

上述爲字符串與時間日期格式互轉的方法

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章