当前位置:网站首页>Pymongo gets a list of data
Pymongo gets a list of data
2022-07-06 06:47:00 【Cute Dai Ma】
At present, there is no way to directly get the whole column of data , Therefore use for Loop data , For example, get all _id:
[i['_id'] for i in coll.find({
}, {
"_id": 1})]
Sample code
from pymongo import MongoClient
import numpy as np
# Specify database
mongo_conn = MongoClient(host='localhost', port=27017)
mongo_db = mongo_conn.get_database("test") # Specify database
coll = mongo_db.get_collection("people")
# Add data
[coll.insert_one({
"num": i, "letter": np.random.choice(a=['a', 'b', 'c', 'd'])}) for i in range(5)]
# Get a column of data :_id
all_num = [i['num'] for i in coll.find({
}, {
"num": 1})] # Get a list of data
print(all_num)
边栏推荐
- Leetcode - 152 product maximum subarray
- Day 245/300 JS forEach 多层嵌套后数据无法更新到对象中
- Day 246/300 ssh连接提示“REMOTE HOST IDENTIFICATION HAS CHANGED! ”
- Day 248/300 关于毕业生如何找工作的思考
- 翻译影视剧字幕,这些特点务必要了解
- Transfert des paramètres de la barre d'adresse de la page de liste basée sur jeecg - boot
- Day 245/300 JS foreach data cannot be updated to the object after multi-layer nesting
- Chapter 7 - thread pool of shared model
- 【软件测试进阶第1步】自动化测试基础知识
- Day 239/300 注册密码长度为8~14个字母数字以及标点符号至少包含2种校验
猜你喜欢
随机推荐
机器学习植物叶片识别
字幕翻译中翻英一分钟多少钱?
LeetCode每日一题(1870. Minimum Speed to Arrive on Time)
专业论文翻译,英文摘要如何写比较好
[ 英语 ] 语法重塑 之 英语学习的核心框架 —— 英语兔学习笔记(1)
MySQL high frequency interview 20 questions, necessary (important)
如何将flv文件转为mp4文件?一个简单的解决办法
C语言_双创建、前插,尾插,遍历,删除
pymongo获取一列数据
生物医学本地化翻译服务
MySQL5.72. MSI installation failed
Machine learning plant leaf recognition
LeetCode每日一题(971. Flip Binary Tree To Match Preorder Traversal)
翻译影视剧字幕,这些特点务必要了解
Map of mL: Based on the adult census income two classification prediction data set (whether the predicted annual income exceeds 50K), use the map value to realize the interpretable case of xgboost mod
Delete external table source data
Modify the list page on the basis of jeecg boot code generation (combined with customized components)
Address bar parameter transmission of list page based on jeecg-boot
关于新冠疫情,常用的英文单词、语句有哪些?
金融德语翻译,北京专业的翻译公司






![[ 英语 ] 语法重塑 之 英语学习的核心框架 —— 英语兔学习笔记(1)](/img/02/41dcdcc6e8f12d76b9c1ef838af97d.png)


