python写入mongodb时间字段格式为ISO

 

#!/usr/bin/env python
#coding=utf-8

import time
from dateutil import parser
from pymongo import MongoClient

now = parser.parse(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))

conn = MongoClient("192.168.1.135:28001", maxPoolSize=None)
my_db = conn['db_pushmsg']
my_collection = my_db['tb_time_test'].insert_one({"id":5, "time": now})

 

posted @ 2023-08-02 11:32  slnngk  阅读(119)  评论(0)    收藏  举报