I_AM_YI
2021-07-20 21:28
采纳率: 78.6%
浏览 139

datetime.datetime'>怎么去掉时分秒


import numpy as np
import pandas as pd
import datetime
from dateutil.parser import parse

data1 = pd.read_csv('result.txt',sep='\t')
data1 = pd.DataFrame(data1)
data1 = np.array(data1)

print(data1[0][3])
data1[0][3] = parse(data1[0][3])
print(type(data1[0][3]))
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • li.siyuan 2021-07-20 21:37
    已采纳

    请采纳

    import datetime
    import time
    
    # time
    print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
    print(time.strftime("%Y-%m-%d", time.localtime()))
    print(time.strftime("%H:%M:%S", time.localtime()))
    # datetime
    print(datetime.datetime.now().strftime("%Y-%m-%d"))
    
    已采纳该答案
    打赏 评论

相关推荐 更多相似问题