python - 以日期格式存储日期时间,使用 Pymongo 烧瓶
问题描述
在使用 pymongo 的 Flask 中,我想在 mongodb 中以日期格式存储日期时间,但它使用我编写的代码以数组或字符串格式存储
我的脚本
date_post=time.strftime("%b %d %Y %H:%M:%S %p") # if i store this in mongo
db it stores in string datatype
date_post=time.strptime(date_post,"%b %d %Y %H:%M:%S %p")
# if i store this in mongo db it stores in Array datatype
print(type(date_post))
jd = mongo.db.rest_create_job_add
job_id =jd.insert({'Country':country,'State':state,'City':city,'Spoc_Name':spoc_name,'Spoc_EMP_ID':spoc_empid,'SPOC_Email':spoc_email,'Spoc_Mobile_No':spoc_mobile,'Spoc_Work_or_Direct_No':spoc_workno,
'date_posted':date_post,'band_range':band_range})
在 mongodb 中它存储date_posted
在其中,Array datatype
而我需要它以日期格式存储。
任何帮助将不胜感激
提前致谢
解决方案
推荐阅读
- azure - 发布 Azure 域
- django - 当文件池在 React 上发布文件时,Django Rest Framework 返回错误请求
- c# - Asp.net Core RequestSizeLimit 仍然执行动作
- ios - 在背景上渲染 Alpha 通道视频 (AVFoundation, Swift)
- swift - 我的图像 addSubview 添加了比预期更大的视图
- docker - 如何检查容器的 IP,获取它并将其添加到具有本地域名解析的 /etc/hosts 文件中
- ffmpeg - 色度键我的过滤白色背景命令有效,但过滤白色和黑色?
- c# - C# 关于对象创建
- python - 如何在 Python 中连接多个数据帧?
- python - 如何在 ANN 中设置 Bias 并将 Sigmoid 更改为 ReLU 函数?