标签:for finish end exe python name script ted 操作
import pymongo
client=pymongo.MongoClient("192.168.14.179",27017)
db=client[‘test‘]
stu=db[‘stu‘]
s1={‘name‘:‘lz‘,‘age‘:27}
s1_id=stu.insert_one(s1).inserted_id
s2=stu.find_one()
for i in stu.find():
print(i)
#方法2
x=stu.find()
x.next()
x.next()
x.next()
x.next()
print(stu.count())
#结果
E:\py1902project\venv\Scripts\python.exe E:/py1902project/xxx/xxx.py
{‘_id‘: ObjectId(‘5ca34a005daca34f28389b11‘), ‘name‘: ‘wang‘, ‘gender‘: 1.0}
{‘_id‘: ObjectId(‘5ca34a0a5daca34f28389b12‘), ‘name‘: ‘chen‘, ‘gender‘: 1.0}
{‘_id‘: ObjectId(‘5ca34a0e5daca34f28389b13‘), ‘name‘: ‘chen‘, ‘gender‘: 1.0}
{‘_id‘: ObjectId(‘5ca34a7a5daca34f28389b14‘), ‘name‘: ‘da‘}
{‘_id‘: ‘1002‘, ‘name‘: ‘wbk‘}
{‘_id‘: ObjectId(‘5ca35d16428ed81704b9f6b6‘), ‘name‘: ‘lz‘, ‘age‘: 27}
6
Process finished with exit code 0
标签:for finish end exe python name script ted 操作
原文地址:https://www.cnblogs.com/ldsice/p/11106429.html