当前位置:网站首页>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)
边栏推荐
- 如何做好互联网金融的英语翻译
- SSO流程分析
- 专业论文翻译,英文摘要如何写比较好
- Biomedical English contract translation, characteristics of Vocabulary Translation
- Latex文字加颜色的三种办法
- Redis Foundation
- In English translation of papers, how to do a good translation?
- 端午节快乐Wish Dragon Boat Festival is happy
- 机器人类专业不同层次院校课程差异性简述-ROS1/ROS2-
- [Yu Yue education] Dunhuang Literature and art reference materials of Zhejiang Normal University
猜你喜欢
女生学软件测试难不难 入门门槛低,学起来还是比较简单的
It is necessary to understand these characteristics in translating subtitles of film and television dramas
LeetCode每日一题(971. Flip Binary Tree To Match Preorder Traversal)
如何将flv文件转为mp4文件?一个简单的解决办法
SQL Server Manager studio (SSMS) installation tutorial
Apache DolphinScheduler源码分析(超详细)
Tms320c665x + Xilinx artix7 DSP + FPGA high speed core board
[English] Verb Classification of grammatical reconstruction -- English rabbit learning notes (2)
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
翻译影视剧字幕,这些特点务必要了解
随机推荐
[Yu Yue education] Dunhuang Literature and art reference materials of Zhejiang Normal University
[ 英語 ] 語法重塑 之 動詞分類 —— 英語兔學習筆記(2)
Biomedical English contract translation, characteristics of Vocabulary Translation
Chinese English comparison: you can do this Best of luck
mysql的基础命令
Pallet management in SAP SD delivery process
Leetcode daily question (1997. first day where you have been in all the rooms)
Advanced MySQL: Basics (1-4 Lectures)
Financial German translation, a professional translation company in Beijing
A method to measure the similarity of time series: from Euclidean distance to DTW and its variants
Monotonic stack
Basic commands of MySQL
查询字段个数
Bitcoinwin (BCW): 借贷平台Celsius隐瞒亏损3.5万枚ETH 或资不抵债
CS通过(CDN+证书)powershell上线详细版
Do you really know the use of idea?
专业论文翻译,英文摘要如何写比较好
国产游戏国际化离不开专业的翻译公司
Fedora/REHL 安装 semanage
商标翻译有什么特点,如何翻译?