Skip to content

Commit 44cf993

Browse files
committed
add docs_release
1 parent fe49e67 commit 44cf993

File tree

111 files changed

+35789
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+35789
-0
lines changed

docs_release/Makefile

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# Makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
PAPER =
8+
BUILDDIR = build
9+
10+
# Internal variables.
11+
PAPEROPT_a4 = -D latex_paper_size=a4
12+
PAPEROPT_letter = -D latex_paper_size=letter
13+
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
14+
# the i18n builder cannot share the environment and doctrees with the others
15+
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
16+
17+
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
18+
19+
help:
20+
@echo "Please use \`make <target>' where <target> is one of"
21+
@echo " html to make standalone HTML files"
22+
@echo " dirhtml to make HTML files named index.html in directories"
23+
@echo " singlehtml to make a single large HTML file"
24+
@echo " pickle to make pickle files"
25+
@echo " json to make JSON files"
26+
@echo " htmlhelp to make HTML files and a HTML help project"
27+
@echo " qthelp to make HTML files and a qthelp project"
28+
@echo " devhelp to make HTML files and a Devhelp project"
29+
@echo " epub to make an epub"
30+
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
31+
@echo " latexpdf to make LaTeX files and run them through pdflatex"
32+
@echo " text to make text files"
33+
@echo " man to make manual pages"
34+
@echo " texinfo to make Texinfo files"
35+
@echo " info to make Texinfo files and run them through makeinfo"
36+
@echo " gettext to make PO message catalogs"
37+
@echo " changes to make an overview of all changed/added/deprecated items"
38+
@echo " linkcheck to check all external links for integrity"
39+
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
40+
41+
clean:
42+
-rm -rf $(BUILDDIR)/*
43+
44+
html:
45+
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
46+
@echo
47+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
48+
49+
dirhtml:
50+
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
51+
@echo
52+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
53+
54+
singlehtml:
55+
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
56+
@echo
57+
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
58+
59+
pickle:
60+
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
61+
@echo
62+
@echo "Build finished; now you can process the pickle files."
63+
64+
json:
65+
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
66+
@echo
67+
@echo "Build finished; now you can process the JSON files."
68+
69+
htmlhelp:
70+
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
71+
@echo
72+
@echo "Build finished; now you can run HTML Help Workshop with the" \
73+
".hhp project file in $(BUILDDIR)/htmlhelp."
74+
75+
qthelp:
76+
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
77+
@echo
78+
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
79+
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
80+
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Pythontutorial.qhcp"
81+
@echo "To view the help file:"
82+
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Pythontutorial.qhc"
83+
84+
devhelp:
85+
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
86+
@echo
87+
@echo "Build finished."
88+
@echo "To view the help file:"
89+
@echo "# mkdir -p $$HOME/.local/share/devhelp/Pythontutorial"
90+
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Pythontutorial"
91+
@echo "# devhelp"
92+
93+
epub:
94+
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
95+
@echo
96+
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
97+
98+
latex:
99+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
100+
@echo
101+
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
102+
@echo "Run \`make' in that directory to run these through (pdf)latex" \
103+
"(use \`make latexpdf' here to do that automatically)."
104+
105+
latexpdf:
106+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
107+
@echo "Running LaTeX files through pdflatex..."
108+
$(MAKE) -C $(BUILDDIR)/latex all-pdf
109+
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
110+
111+
text:
112+
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
113+
@echo
114+
@echo "Build finished. The text files are in $(BUILDDIR)/text."
115+
116+
man:
117+
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
118+
@echo
119+
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
120+
121+
texinfo:
122+
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
123+
@echo
124+
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
125+
@echo "Run \`make' in that directory to run these through makeinfo" \
126+
"(use \`make info' here to do that automatically)."
127+
128+
info:
129+
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
130+
@echo "Running Texinfo files through makeinfo..."
131+
make -C $(BUILDDIR)/texinfo info
132+
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
133+
134+
gettext:
135+
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
136+
@echo
137+
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
138+
139+
changes:
140+
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
141+
@echo
142+
@echo "The overview file is in $(BUILDDIR)/changes."
143+
144+
linkcheck:
145+
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
146+
@echo
147+
@echo "Link check complete; look for any errors in the above output " \
148+
"or in $(BUILDDIR)/linkcheck/output.txt."
149+
150+
doctest:
151+
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
152+
@echo "Testing of doctests in the sources finished, look at the " \
153+
"results in $(BUILDDIR)/doctest/output.txt."

docs_release/html/.buildinfo

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Sphinx build info version 1
2+
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3+
config: 140fb1222a934ddb93f559dc5229263a
4+
tags: 645f666f9bcd5a90fca523b33c5a78b7
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
.. _tut-appendix:
2+
3+
********
4+
附录
5+
********
6+
7+
8+
.. _tut-interac:
9+
10+
交互模式
11+
================
12+
13+
.. _tut-error:
14+
15+
错误处理
16+
--------------
17+
18+
当错误发生时,解释器打印一个错误信息和堆栈跟踪。在交互模式下,它返回主提示符;当输入来自文件的时候,在打印堆栈跟踪后以非零退出状态退出。(在 `try <https://docs.python.org/3/reference/compound_stmts.html#try>`_ 声明中被 `except <https://docs.python.org/3/reference/compound_stmts.html#except>`_ 子句捕捉到的异常在这种情况下不是错误。)有些错误是非常致命的会导致一个非零状态的退出;这也适用于内部错误以及某些情况的内存耗尽。所有的错误信息都写入到标准错误流;来自执行的命令的普通输出写入到标准输出。
19+
20+
输入中断符(通常是 Control-C 或者 DEL)到主或者从提示符中慧取消输入并且返回到主提示。[#]_ 当命令执行中输入中断符会引起 `KeyboardInterrupt <https://docs.python.org/3/library/exceptions.html#KeyboardInterrupt>`_ 异常,这个异常能够被一个 `try <https://docs.python.org/3/reference/compound_stmts.html#try>`_ 声明处理。
21+
22+
23+
.. _tut-scripts:
24+
25+
可执行 Python 脚本
26+
-------------------------
27+
28+
在 BSD'ish Unix 系统上,Python 脚本可直接执行,像 shell 脚本一样,只需要把下面内容加入到 ::
29+
30+
#!/usr/bin/env python3.5
31+
32+
(假设 python 解释器在用户的 :envvar:`PATH` 中)脚本的开头,并给予该文件的可执行模式。``#!`` 必须是文件的头两个字符。在一些系统上,第一行必须以 Unix-style 的行结束符(``'\n'``)结束,不能以 Windows 的行结束符(``'\r\n'``)。 注意 ``'#'`` 在 Python 中是用于注释的。
33+
34+
使用 :program:`chmod` 命令能够给予脚本执行模式或者权限。
35+
36+
.. code-block:: bash
37+
38+
$ chmod +x myscript.py
39+
40+
在 Windows 系统上,没有一个 “可执行模式” 的概念。Python 安装器会自动地把 ``.py`` 文件和 ``python.exe`` 关联起来,因此双击 Python 分拣将会把它当成一个脚本运行。文件扩展名也可以是 ``.pyw``,在这种情况下,运行时不会出现控制台窗口。
41+
42+
43+
.. _tut-startup:
44+
45+
交互式启动文件
46+
----------------------------
47+
48+
当你使用交互式 Python 的时候,它常常很方便地执行一些命令在每次解释器启动时。你可以这样做:设置一个名为 `PYTHONSTARTUP <https://docs.python.org/3/using/cmdline.html#envvar-PYTHONSTARTUP>`_ 的环境变量为包含你的启动命令的文件名。这跟 Unix shells 的 :file:`.profile` 特点有些类似。
49+
50+
这个文件在交互式会话中是只读的,在当 Python 从脚本中读取命令,以及在当 :file:`/dev/tty` 被作为明确的命令源的时候不只是可读的。该文件在交互式命令被执行的时候在相同的命名空间中能够被执行,因此在交互式会话中定义或者导入的对象能够无需授权就能使用。你也能在文件中更改提示 ``sys.ps1`` 和 ``sys.ps2``。
51+
52+
如果你想要从当前目录中读取一个附加的启动文件,你可以在全局启动文件中编写代码像这样:``if
53+
os.path.isfile('.pythonrc.py'): exec(open('.pythonrc.py').read())``。如果你想要在脚本中使用启动文件的话,你必须在脚本中明确要这么做::
54+
55+
import os
56+
filename = os.environ.get('PYTHONSTARTUP')
57+
if filename and os.path.isfile(filename):
58+
with open(filename) as fobj:
59+
startup_file = fobj.read()
60+
exec(startup_file)
61+
62+
63+
.. _tut-customize:
64+
65+
定制模块
66+
-------------------------
67+
68+
Python 提供两个钩子为了让你们定制 :mod:`sitecustomize` 和 :mod:`usercustomize`。为了看看它的工作机制的话,你必须首先找到你的用户 site-packages 目录的位置。启动 Python 并且运行这段代码::
69+
70+
>>> import site
71+
>>> site.getusersitepackages()
72+
'/home/user/.local/lib/python3.4/site-packages'
73+
74+
现在你可以创建一个名为 :file:`usercustomize.py` 的文件在你的用户 site-packages 目录,并且在里面放置你想要的任何内容。它会影响 Python 的每一次调用,除非它以 `-s <https://docs.python.org/3/using/cmdline.html#cmdoption-s>`_ (禁用自动导入)选项启动。
75+
76+
:mod:`sitecustomize` 以同样地方式工作,但是通常由是机器的管理员创建在全局的 site-packages 目录中,并且是在 :mod:`usercustomize` 之前导入。请参阅 `site <https://docs.python.org/3/library/site.html#module-site>`_ 模块获取更多信息。
77+
78+
79+
.. rubric:: Footnotes
80+
81+
.. [#] GNU 的 Readline 包的问题可能会阻止这种做法。
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.. _tut-intro:
2+
3+
**********************
4+
开胃菜
5+
**********************
6+
7+
如果你要用计算机做很多工作,最后你会发现有一些任务你更希望用自动化的方式进行处理。比如,你想要在大量的文本文件中执行查找/替换,或者以复杂的方式对大量的图片进行重命名和整理。也许你想要编写一个小型的自定义数据库、一个特殊的 GUI 应用程序或一个简单的小游戏。
8+
9+
如果你是一名专业的软件开发者,可能你必须使用几种 C/C++/JAVA 类库,并且发现通常编写/编译/测试/重新编译的周期是如此漫长。也许你正在为这些类库编写测试用例,但是发现这是一个让人烦躁的工作。又或者你已经完成了一个可以使用扩展语言的程序,但你并不想为此重新设计并实现一套全新的语言。
10+
11+
那么 Python 正是你所需要的语言。
12+
13+
虽然你能够通过编写 Unix shell 脚本或 Windows 批处理文件来处理其中的某些任务,但 Shell 脚本更适合移动文件或修改文本数据,并不适合编写 GUI 应用程序或游戏;虽然你能够使用 C/C++/JAVA 编写程序,但即使编写一个简单的 first-draft 程序也有可能耗费大量的开发时间。相比之下,Python 更易于使用,无论在 Windows、Mac OS X 或 Unix 操作系统上它都会帮助你更快地完成任务。
14+
15+
虽然 Python 易于使用,但它却是一门完整的编程语言;与 Shell 脚本或批处理文件相比,它为编写大型程序提供了更多的结构和支持。另一方面,Python 提供了比 C 更多的错误检查,并且作为一门 *高级语言*,它内置支持高级的数据结构类型,例如:灵活的数组和字典。因其更多的通用数据类型,Python 比 Awk 甚至 Perl 都适用于更多问题领域,至少大多数事情在 Python 中与其他语言同样简单。
16+
17+
Python 允许你将程序分割为不同的模块,以便在其他的 Python 程序中重用。Python 内置提供了大量的标准模块,你可以将其用作程序的基础,或者作为学习 Python 编程的示例。这些模块提供了诸如文件 I/O、系统调用、Socket 支持,甚至类似 Tk 的用户图形界面(GUI)工具包接口。
18+
19+
Python 是一门解释型语言,因为无需编译和链接,你可以在程序开发中节省宝贵的时间。Python 解释器可以交互的使用,这使得试验语言的特性、编写临时程序或在自底向上的程序开发中测试方法非常容易。你甚至还可以把它当做一个桌面计算器。
20+
21+
Python 让程序编写的紧凑和可读。用 Python 编写的程序通常比同样的 C、C++ 或 Java 程序更短小,这是因为以下几个原因::
22+
23+
* 高级数据结构使你可以在一条语句中表达复杂的操作;
24+
25+
* 语句组使用缩进代替开始和结束大括号来组织;
26+
27+
* 变量或参数无需声明。
28+
29+
Python 是 *可扩展* 的:如果你会 C 语言编程便可以轻易地为解释器添加内置函数或模块,或者为了对性能瓶颈作优化,或者将 Python 程序与只有二进制形式的库(比如某个专业的商业图形库)连接起来。一旦你真正掌握了它,你可以将 Python 解释器集成进某个 C 应用程序,并把它当作那个程序的扩展或命令行语言。
30+
31+
顺便说一句,这个语言的名字来自于 BBC 的 “Monty Python’s Flying Cirecus” 节目,和爬行类动物没有任何关系。在文档中引用 Monty Python 的典故不仅可行,而且值得鼓励!
32+
33+
现在你已经为 Python 兴奋不已了吧,大概想要领略一些更多的细节!学习一门语言最好的方法就是使用它,本指南推荐你边读边使用 Python 解释器练习。
34+
35+
下一节中,我们将解释 Python 解释器的用法。这是很简单的一件事情,但它有助于试验后面的例子。
36+
37+
本手册剩下的部分将通过示例介绍 Python 语言及系统的诸多特性,开始是简单的语法、数据类型和表达式,接着介绍函数与模块,最后涉及异常和自定义类这样的高级内容。

0 commit comments

Comments
 (0)