1str -> date

import datetime

detester = ‘2017-01-01'
date = datetime.datetime.strptime(detester,’%Y-%m-%d')

2date -> str

import datetime

date = datetime.now()

detester = date.strftime(‘%Y-%m-%d')

--------------------- 本文来自 criller 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/criller/article/details/73715057?utm_source=copy 

PS:若时间格式为前段传回,有可能字符串后面有空格,会报错。可len()查看处理

相关文章:

  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2021-07-17
  • 2022-02-08
  • 2022-02-04
  • 2022-12-23
猜你喜欢
  • 2021-10-05
  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
  • 2021-12-18
  • 2022-02-13
  • 2022-12-23
相关资源
相似解决方案