Checkout
- Python 输出输出
#coding=utf-8
name = 'carson'
age = 18
print('name: %s, age: %d'%(name,age))
place = input('And where are you want to go?') # must string type, such as 'Beijing'
# place = raw_input('And where are you want to go?') # raw input, such as Beijing
print('ok, we will go to %s, now!'%place)
- PyMongo 连接数据库
# install pip3
apt-get install python3-pip
# install PyMongo
pip3 install pymongo
pip install pymongo
# start:python
from pymongo import MongoClient
client = MongoClient()
db_school = client.school
clc_student = db_school.student
new_stu = {'name': 'carson', 'age': 18, 'sex': 'male'}
clc_student.insert(new_stu)
many_stu = clc_student.find()
for each in many_stu:
print(each['name'])
var fisr_carson = clc_student.findOne({'name': 'carson'})
clc_student.update({'name': 'carson'}, {'sex': 'female'})
clc-student.update_one({'name': 'carson'}, {'age': 16})
clo_student.update_many({'name': 'carson', {'sex': 'efmale'}})
clc_student.delete_one({'name': 'carson'})
clc_studnet.delete_many({'name': 'carson'})