logo
  • 教程列表
  • SO官方文檔
  • 日期格式
    • 兩個日期之間的時間
    • 將 datetime 物件輸出到字串
    • 將字串解析為 datetime 物件
  1. StackOverflow 文件
  2. Python Language 教程
  3. 日期格式
  4. 將字串解析為 datetime 物件

將字串解析為 datetime 物件

Created: November-22, 2018

使用 C 標準格式程式碼 。

from datetime import datetime
datetime_string = 'Oct 1 2016, 00:00:00'
datetime_string_format = '%b %d %Y, %H:%M:%S'
datetime.strptime(datetime_string, datetime_string_format)
# datetime.datetime(2016, 10, 1, 0, 0)
  • 將 datetime 物件輸出到字串

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明