One - One Code All

Blog Content

python日期与字符串互转

Python   2013-10-18 21:56:15

字符串转日期:


import datetime

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

日期转字符串:

import datetime

date = datetime.now()

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


求时间差的秒数

(date2 - date1).seconds


上一篇:julia安装python相关的包时设定python环境
下一篇:python处理dataframe错误:ValueError: If using all scalar values, you must pass an index

The minute you think of giving up, think of the reason why you held on so long.