@@ -711,93 +711,106 @@ msgid ""
711711"marks the Python-level file object as being closed, but does *not* close the"
712712" associated C file descriptor."
713713msgstr ""
714+ "但由于 stdin,stdout 和 stderr 在 C 中的特殊地位,在 Python 中也会对它们做特殊处理。运行 "
715+ "``sys.stdout.close()`` 会将 Python 的文件对象标记为已关闭,但是*不会*关闭与之关联的文件描述符。"
714716
715717#: ../../faq/library.rst:646
716718msgid ""
717719"To close the underlying C file descriptor for one of these three, you should"
718720" first be sure that's what you really want to do (e.g., you may confuse "
719721"extension modules trying to do I/O). If it is, use :func:`os.close`::"
720722msgstr ""
723+ "要关闭这三者的 C 文件描述符的话,首先你应该确认确实需要关闭它(比如,这可能会影响到处理 I/O 的拓展)。如果确实需要这么做的话,使用 "
724+ ":func:`os.close`:"
721725
722726#: ../../faq/library.rst:654
723727msgid "Or you can use the numeric constants 0, 1 and 2, respectively."
724- msgstr ""
728+ msgstr "或者也可以使用常量 0,1,2 代替。 "
725729
726730#: ../../faq/library.rst:658
727731msgid "Network/Internet Programming"
728- msgstr ""
732+ msgstr "网络 / Internet 编程 "
729733
730734#: ../../faq/library.rst:661
731735msgid "What WWW tools are there for Python?"
732- msgstr ""
736+ msgstr "Python 中的 WWW 工具是什么? "
733737
734738#: ../../faq/library.rst:663
735739msgid ""
736740"See the chapters titled :ref:`internet` and :ref:`netdata` in the Library "
737741"Reference Manual. Python has many modules that will help you build server-"
738742"side and client-side web systems."
739743msgstr ""
744+ "参阅代码库参考手册中 :ref:`internet` 和 :ref:`netdata` 这两章的内容。Python 有大量模块来帮助你构建服务端和客户端"
745+ " web 系统。"
740746
741747#: ../../faq/library.rst:669
742748msgid ""
743749"A summary of available frameworks is maintained by Paul Boddie at "
744750"https://wiki.python.org/moin/WebProgramming\\ ."
745751msgstr ""
752+ "Paul Boddie 维护了一份可用框架的概览,见 https://wiki.python.org/moin/WebProgramming 。"
746753
747754#: ../../faq/library.rst:672
748755msgid ""
749756"Cameron Laird maintains a useful set of pages about Python web technologies "
750757"at http://phaseit.net/claird/comp.lang.python/web_python."
751758msgstr ""
759+ "Cameron Laird 维护了一份关于 Python web 技术的实用网页的集合,见 "
760+ "http://phaseit.net/claird/comp.lang.python/web_python 。"
752761
753762#: ../../faq/library.rst:677
754763msgid "How can I mimic CGI form submission (METHOD=POST)?"
755- msgstr ""
764+ msgstr "怎样模拟发送 CGI 表单(METHOD=POST)? "
756765
757766#: ../../faq/library.rst:679
758767msgid ""
759768"I would like to retrieve web pages that are the result of POSTing a form. Is"
760769" there existing code that would let me do this easily?"
761- msgstr ""
770+ msgstr "我需要通过 POST 表单获取网页,有什么代码能简单做到吗? "
762771
763772#: ../../faq/library.rst:682
764773msgid "Yes. Here's a simple example that uses urllib.request::"
765- msgstr ""
774+ msgstr "是的,这里有一个使用 urllib.request 的简单例子: "
766775
767776#: ../../faq/library.rst:697
768777msgid ""
769778"Note that in general for percent-encoded POST operations, query strings must"
770779" be quoted using :func:`urllib.parse.urlencode`. For example, to send "
771780"``name=Guy Steele, Jr.``::"
772781msgstr ""
782+ "注意,通常在百分号编码的 POST 操作中,查询字符串必须使用 :func:`urllib.parse.urlencode` "
783+ "处理一下。举个例子,如果要发送 ``name=Guy Steele, Jr.`` 的话:"
773784
774785#: ../../faq/library.rst:705
775786msgid ":ref:`urllib-howto` for extensive examples."
776- msgstr ""
787+ msgstr "查看 :ref:`urllib-howto` 获取更多示例。 "
777788
778789#: ../../faq/library.rst:709
779790msgid "What module should I use to help with generating HTML?"
780- msgstr ""
791+ msgstr "生成 HTML 需要使用什么模块? "
781792
782793#: ../../faq/library.rst:713
783794msgid ""
784795"You can find a collection of useful links on the `Web Programming wiki page "
785796"<https://wiki.python.org/moin/WebProgramming>`_."
786797msgstr ""
798+ "你可以在 `Web 编程 wiki 页面 <https://wiki.python.org/moin/WebProgramming>`_ "
799+ "找到许多有用的链接。"
787800
788801#: ../../faq/library.rst:718
789802msgid "How do I send mail from a Python script?"
790- msgstr ""
803+ msgstr "怎样使用 Python 脚本发送邮件? "
791804
792805#: ../../faq/library.rst:720
793806msgid "Use the standard library module :mod:`smtplib`."
794- msgstr ""
807+ msgstr "使用 :mod:`smtplib` 标准库模块。 "
795808
796809#: ../../faq/library.rst:722
797810msgid ""
798811"Here's a very simple interactive mail sender that uses it. This method will"
799812" work on any host that supports an SMTP listener. ::"
800- msgstr ""
813+ msgstr "下面是一个很简单的交互式发送邮件的代码。这个方法适用于任何支持 SMTP 协议的主机。 "
801814
802815#: ../../faq/library.rst:742
803816msgid ""
@@ -806,16 +819,19 @@ msgid ""
806819"``/usr/sbin/sendmail``. The sendmail manual page will help you out. Here's"
807820" some sample code::"
808821msgstr ""
822+ "在 Unix 系统中还可以使用 sendmail。sendmail 程序的位置在不同系统中不一样,有时是在 "
823+ "``/usr/lib/sendmail``,有时是在 ``/usr/sbin/sendmail``。sendmail "
824+ "手册页面会对你有所帮助。以下是示例代码:"
809825
810826#: ../../faq/library.rst:762
811827msgid "How do I avoid blocking in the connect() method of a socket?"
812- msgstr ""
828+ msgstr "socket 的 connect() 方法怎样避免阻塞? "
813829
814830#: ../../faq/library.rst:764
815831msgid ""
816832"The :mod:`select` module is commonly used to help with asynchronous I/O on "
817833"sockets."
818- msgstr ""
834+ msgstr "通常会用 :mod:`select` 模块处理 socket 异步 I/O。 "
819835
820836#: ../../faq/library.rst:767
821837msgid ""
@@ -826,6 +842,9 @@ msgid ""
826842"progress, but hasn't finished yet. Different OSes will return different "
827843"values, so you're going to have to check what's returned on your system."
828844msgstr ""
845+ "要避免 TCP 连接阻塞,你可以设置将 socket 设置为非阻塞模式。此时当调用 ``connect()`` "
846+ "时,要么连接会立刻建立好(几乎不可能),要么会收到一个包含了错误码 ``.error`` 的异常。``errno.EINPROGRESS`` "
847+ "表示连接正在进行,但还没有完成。不同的系统会返回不同的值,所以你需要确认你使用的系统会返回什么。"
829848
830849#: ../../faq/library.rst:774
831850msgid ""
@@ -834,6 +853,9 @@ msgid ""
834853"again later -- ``0`` or ``errno.EISCONN`` indicate that you're connected -- "
835854"or you can pass this socket to select to check if it's writable."
836855msgstr ""
856+ "你可以使用 ``connect_ex()`` 方法来避免产生异常。这个方法只会返回错误码。如果需要轮询的话,你可以再次调用 "
857+ "``connect_ex()`` —— ``0`` 或 ``errno.EISCONN`` 表示连接已建立,或者你也可以用 select 检查这个 "
858+ "socket 是否可写。"
837859
838860#: ../../faq/library.rst:780
839861msgid ""
@@ -842,18 +864,20 @@ msgid ""
842864"<https://twistedmatrix.com/trac/>`_ library is a popular and feature-rich "
843865"alternative."
844866msgstr ""
867+ ":mod:`asyncore` 模块提供了编写非阻塞网络代码框架性的方法。第三方的 `Twisted "
868+ "<https://twistedmatrix.com/trac/>`_ 库也很常用且功能强大。"
845869
846870#: ../../faq/library.rst:787
847871msgid "Databases"
848- msgstr ""
872+ msgstr "数据库 "
849873
850874#: ../../faq/library.rst:790
851875msgid "Are there any interfaces to database packages in Python?"
852- msgstr ""
876+ msgstr "Python 中有数据库包的接口吗? "
853877
854878#: ../../faq/library.rst:792
855879msgid "Yes."
856- msgstr ""
880+ msgstr "当然。 "
857881
858882#: ../../faq/library.rst:794
859883msgid ""
@@ -862,6 +886,8 @@ msgid ""
862886":mod:`sqlite3` module, which provides a lightweight disk-based relational "
863887"database."
864888msgstr ""
889+ "Python 标准库中集成了基于磁盘的哈希数据库接口,例如 :mod:`DBM <dbm.ndbm>` 和 `mod:`GDBM "
890+ "<dbm.gnu>`。除此之外还有 :mod:`sqlite3` 模块,该模块提供了一个轻量级的基于磁盘的关系型数据库。"
865891
866892#: ../../faq/library.rst:799
867893msgid ""
0 commit comments