 Python3 基础教程 - 廖雪峰http://www.yeayee.com/ 264/531 什么叫“多任务”呢?简单地说,就是操作系统可以同时运行多个任务。 打个比方,你一边在用浏览器上网,一边在听 MP3,一边在用 Word 赶 作业,这就是多任务,至少同时有 3 个任务正在运行。还有很多任务悄 悄地在后台同时运行着,只是桌面上没有显示而已。 现在,多核 CPU 已经非常普及了,但是,即使过去的单核 CPU,也可 以执行多任务。由于 无论是多进程还是多线程,只要数量一多,效率肯定上不去,为什么呢? 我们打个比方,假设你不幸正在准备中考,每天晚上需要做语文、数学、 英语、物理、化学这 5 科的作业,每项作业耗时 1 小时。 如果你先花 1 小时做语文作业,做完了,再花 1 小时做数学作业,这样, 依次全部做完,一共花 5 小时,这种方式称为单任务模型,或者批处理 任务模型。 假设你打算切换到多任务模型,可以先做 1 分钟语文,再切换到数学作 快,这种 方式就和单核 CPU 执行多任务是一样的了,以幼儿园小朋友的眼光来 看,你就正在同时写 5 科作业。 但是,切换作业是有代价的,比如从语文切到数学,要先收拾桌子上的 语文书本、钢笔(这叫保存现场),然后,打开数学课本、找出圆规直 尺(这叫准备新环境),才能开始做数学作业。操作系统在切换进程或 者线程时也是一样的,它需要先保存当前执行的现场环境(CPU 寄存器 状态、内存页0 码力 | 531 页 | 5.15 MB | 1 年前3 Python3 基础教程 - 廖雪峰http://www.yeayee.com/ 264/531 什么叫“多任务”呢?简单地说,就是操作系统可以同时运行多个任务。 打个比方,你一边在用浏览器上网,一边在听 MP3,一边在用 Word 赶 作业,这就是多任务,至少同时有 3 个任务正在运行。还有很多任务悄 悄地在后台同时运行着,只是桌面上没有显示而已。 现在,多核 CPU 已经非常普及了,但是,即使过去的单核 CPU,也可 以执行多任务。由于 无论是多进程还是多线程,只要数量一多,效率肯定上不去,为什么呢? 我们打个比方,假设你不幸正在准备中考,每天晚上需要做语文、数学、 英语、物理、化学这 5 科的作业,每项作业耗时 1 小时。 如果你先花 1 小时做语文作业,做完了,再花 1 小时做数学作业,这样, 依次全部做完,一共花 5 小时,这种方式称为单任务模型,或者批处理 任务模型。 假设你打算切换到多任务模型,可以先做 1 分钟语文,再切换到数学作 快,这种 方式就和单核 CPU 执行多任务是一样的了,以幼儿园小朋友的眼光来 看,你就正在同时写 5 科作业。 但是,切换作业是有代价的,比如从语文切到数学,要先收拾桌子上的 语文书本、钢笔(这叫保存现场),然后,打开数学课本、找出圆规直 尺(这叫准备新环境),才能开始做数学作业。操作系统在切换进程或 者线程时也是一样的,它需要先保存当前执行的现场环境(CPU 寄存器 状态、内存页0 码力 | 531 页 | 5.15 MB | 1 年前3
 python3学习手册Thread(target=scheduler_thread) thread.start() schedule.run_all() # 立即运行所有作业 schedule.run_all(delay_seconds=10) # 立即运行所有作业,每次 作业间隔10秒 all_jobs = schedule.get_jobs("jobxx") # 获取指定标签的所有 任务 schedule.clear("jobxx")0 码力 | 213 页 | 3.53 MB | 1 年前3 python3学习手册Thread(target=scheduler_thread) thread.start() schedule.run_all() # 立即运行所有作业 schedule.run_all(delay_seconds=10) # 立即运行所有作业,每次 作业间隔10秒 all_jobs = schedule.get_jobs("jobxx") # 获取指定标签的所有 任务 schedule.clear("jobxx")0 码力 | 213 页 | 3.53 MB | 1 年前3
 sqlalchemy tutoriali About the Tutorial SQLAlchemy is a popular SQL toolkit and Object Relational Mapper. It is written in Python and gives full power and flexibility of SQL to an application developer cross-platform software released under MIT license. SQLAlchemy is famous for its object-relational mapper (ORM), using which classes can be mapped to the database, thereby allowing the object model and SQLAlchemy 1 SQLAlchemy is a popular SQL toolkit and Object Relational Mapper. It is written in Python and gives full power and flexibility of SQL to an application developer0 码力 | 92 页 | 1.77 MB | 1 年前3 sqlalchemy tutoriali About the Tutorial SQLAlchemy is a popular SQL toolkit and Object Relational Mapper. It is written in Python and gives full power and flexibility of SQL to an application developer cross-platform software released under MIT license. SQLAlchemy is famous for its object-relational mapper (ORM), using which classes can be mapped to the database, thereby allowing the object model and SQLAlchemy 1 SQLAlchemy is a popular SQL toolkit and Object Relational Mapper. It is written in Python and gives full power and flexibility of SQL to an application developer0 码力 | 92 页 | 1.77 MB | 1 年前3
 Flask Documentation (1.1.x)Flask-SQLAlchemy Extension Because SQLAlchemy is a common database abstraction layer and object relational mapper that requires a little bit of configuration effort, there is a Flask extension that handles that into models.py): from sqlalchemy import Table, Column, Integer, String from sqlalchemy.orm import mapper from yourapplication.database import metadata, db_session class User(object): query = db_session primary_key=True), Column('name', String(50), unique=True), Column('email', String(120), unique=True) ) mapper(User, users) Querying and inserting works exactly the same as in the example above. SQL Abstraction0 码力 | 428 页 | 895.98 KB | 1 年前3 Flask Documentation (1.1.x)Flask-SQLAlchemy Extension Because SQLAlchemy is a common database abstraction layer and object relational mapper that requires a little bit of configuration effort, there is a Flask extension that handles that into models.py): from sqlalchemy import Table, Column, Integer, String from sqlalchemy.orm import mapper from yourapplication.database import metadata, db_session class User(object): query = db_session primary_key=True), Column('name', String(50), unique=True), Column('email', String(120), unique=True) ) mapper(User, users) Querying and inserting works exactly the same as in the example above. SQL Abstraction0 码力 | 428 页 | 895.98 KB | 1 年前3
 Flask Documentation (1.1.x)Flask-SQLAlchemy Extension Because SQLAlchemy is a common database abstraction layer and object relational mapper that requires a little bit of configuration effort, there is a Flask extension that handles that into models.py): from sqlalchemy import Table, Column, Integer, String from sqlalchemy.orm import mapper from yourapplication.database import metadata, db_session class User(object): query = db_session primary_key=True), Column('name', String(50), unique=True), Column('email', String(120), unique=True) ) mapper(User, users) Querying and inserting works exactly the same as in the example above. SQL Abstraction0 码力 | 291 页 | 1.25 MB | 1 年前3 Flask Documentation (1.1.x)Flask-SQLAlchemy Extension Because SQLAlchemy is a common database abstraction layer and object relational mapper that requires a little bit of configuration effort, there is a Flask extension that handles that into models.py): from sqlalchemy import Table, Column, Integer, String from sqlalchemy.orm import mapper from yourapplication.database import metadata, db_session class User(object): query = db_session primary_key=True), Column('name', String(50), unique=True), Column('email', String(120), unique=True) ) mapper(User, users) Querying and inserting works exactly the same as in the example above. SQL Abstraction0 码力 | 291 页 | 1.25 MB | 1 年前3
 Django 1.8.x DocumentationDesign your model Although you can use Django without a database, it comes with an object-relational mapper in which you describe your database layout in Python code. The data-model syntax offers many rich SQL If you find yourself needing to write an SQL query that is too complex for Django’s database-mapper to handle, you can fall back on writing SQL by hand. Django has a couple of options for writing raw (positional, keyword) and values of the view arguments. Django provides a solution such that the URL mapper is the only repository of the URL design. You feed it with your URLconf and then it can be used in0 码力 | 1685 页 | 6.01 MB | 1 年前3 Django 1.8.x DocumentationDesign your model Although you can use Django without a database, it comes with an object-relational mapper in which you describe your database layout in Python code. The data-model syntax offers many rich SQL If you find yourself needing to write an SQL query that is too complex for Django’s database-mapper to handle, you can fall back on writing SQL by hand. Django has a couple of options for writing raw (positional, keyword) and values of the view arguments. Django provides a solution such that the URL mapper is the only repository of the URL design. You feed it with your URLconf and then it can be used in0 码力 | 1685 页 | 6.01 MB | 1 年前3
 Django 1.8.x DocumentationDesign your model Although you can use Django without a database, it comes with an object-relational mapper in which you describe your database layout in Python code. The data-model syntax offers many rich SQL If you find yourself needing to write an SQL query that is too complex for Django’s database-mapper to handle, you can fall back on writing SQL by hand. Django has a couple of options for writing raw (positional, keyword) and values of the view arguments. Django provides a solution such that the URL mapper is the only repository of the URL design. You feed it with your URLconf and then it can be used in0 码力 | 2454 页 | 2.85 MB | 1 年前3 Django 1.8.x DocumentationDesign your model Although you can use Django without a database, it comes with an object-relational mapper in which you describe your database layout in Python code. The data-model syntax offers many rich SQL If you find yourself needing to write an SQL query that is too complex for Django’s database-mapper to handle, you can fall back on writing SQL by hand. Django has a couple of options for writing raw (positional, keyword) and values of the view arguments. Django provides a solution such that the URL mapper is the only repository of the URL design. You feed it with your URLconf and then it can be used in0 码力 | 2454 页 | 2.85 MB | 1 年前3
 Django 1.10.x DocumentationDesign your model Although you can use Django without a database, it comes with an object-relational mapper in which you describe your database layout in Python code. The data-model syntax offers many rich SQL If you find yourself needing to write an SQL query that is too complex for Django’s database-mapper to handle, you can fall back on writing SQL by hand. Django has a couple of options for writing raw (positional, keyword) and values of the view arguments. Django provides a solution such that the URL mapper is the only repository of the URL design. You feed it with your URLconf and then it can be used in0 码力 | 1817 页 | 6.19 MB | 1 年前3 Django 1.10.x DocumentationDesign your model Although you can use Django without a database, it comes with an object-relational mapper in which you describe your database layout in Python code. The data-model syntax offers many rich SQL If you find yourself needing to write an SQL query that is too complex for Django’s database-mapper to handle, you can fall back on writing SQL by hand. Django has a couple of options for writing raw (positional, keyword) and values of the view arguments. Django provides a solution such that the URL mapper is the only repository of the URL design. You feed it with your URLconf and then it can be used in0 码力 | 1817 页 | 6.19 MB | 1 年前3
 Django 1.10.x DocumentationDesign your model Although you can use Django without a database, it comes with an object-relational mapper in which you describe your database layout in Python code. The data-model syntax offers many rich SQL If you find yourself needing to write an SQL query that is too complex for Django’s database-mapper to handle, you can fall back on writing SQL by hand. Django has a couple of options for writing raw (positional, keyword) and values of the view arguments. Django provides a solution such that the URL mapper is the only repository of the URL design. You feed it with your URLconf and then it can be used in0 码力 | 2538 页 | 2.59 MB | 1 年前3 Django 1.10.x DocumentationDesign your model Although you can use Django without a database, it comes with an object-relational mapper in which you describe your database layout in Python code. The data-model syntax offers many rich SQL If you find yourself needing to write an SQL query that is too complex for Django’s database-mapper to handle, you can fall back on writing SQL by hand. Django has a couple of options for writing raw (positional, keyword) and values of the view arguments. Django provides a solution such that the URL mapper is the only repository of the URL design. You feed it with your URLconf and then it can be used in0 码力 | 2538 页 | 2.59 MB | 1 年前3
 Django 2.1.x DocumentationDesign your model Although you can use Django without a database, it comes with an object-relational mapper in which you describe your database layout in Python code. The data-model syntax offers many rich SQL If you find yourself needing to write an SQL query that is too complex for Django’s database-mapper to handle, you can fall back on writing SQL by hand. Django has a couple of options for writing raw (positional, keyword) and values of the view arguments. Django provides a solution such that the URL mapper is the only repository of the URL design. You feed it with your URLconf and then it can be used in0 码力 | 1910 页 | 6.49 MB | 1 年前3 Django 2.1.x DocumentationDesign your model Although you can use Django without a database, it comes with an object-relational mapper in which you describe your database layout in Python code. The data-model syntax offers many rich SQL If you find yourself needing to write an SQL query that is too complex for Django’s database-mapper to handle, you can fall back on writing SQL by hand. Django has a couple of options for writing raw (positional, keyword) and values of the view arguments. Django provides a solution such that the URL mapper is the only repository of the URL design. You feed it with your URLconf and then it can be used in0 码力 | 1910 页 | 6.49 MB | 1 年前3
共 61 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7














 
 