Expand Up @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.10\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2022-05-21 17:35 +0000\n" "POT-Creation-Date: 2022-06-10 00:16 +0000\n" "PO-Revision-Date: 2018-05-23 14:35+0000\n" "Last-Translator: Adrian Liaw <adrianliaw2000@gmail.com>\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" Expand Down Expand Up @@ -519,53 +519,58 @@ msgstr "" #: ../../faq/library.rst:486 msgid "" "The :mod:`shutil` module contains a :func:`~shutil.copyfile` function. Note " "that on MacOS 9 it doesn't copy the resource fork and Finder info." "The :mod:`shutil` module contains a :func:`~shutil.copyfile` function. Note " "that on Windows NTFS volumes, it does not copy `alternate data streams " "<https://en.wikipedia.org/wiki/NTFS#Alternate_data_stream_(ADS)>`_ nor " "`resource forks <https://en.wikipedia.org/wiki/Resource_fork>`__ on macOS HFS" "+ volumes, though both are now rarely used. It also doesn't copy file " "permissions and metadata, though using :func:`shutil.copy2` instead will " "preserve most (though not all) of it." msgstr "" #: ../../faq/library.rst:491 #: ../../faq/library.rst:497 msgid "How do I read (or write) binary data?" msgstr "" #: ../../faq/library.rst:493 #: ../../faq/library.rst:499 msgid "" "To read or write complex binary data formats, it's best to use the :mod:" "`struct` module. It allows you to take a string containing binary data " "(usually numbers) and convert it to Python objects; and vice versa." msgstr "" #: ../../faq/library.rst:497 #: ../../faq/library.rst:503 msgid "" "For example, the following code reads two 2-byte integers and one 4-byte " "integer in big-endian format from a file::" msgstr "" #: ../../faq/library.rst:506 #: ../../faq/library.rst:512 msgid "" "The '>' in the format string forces big-endian data; the letter 'h' reads " "one \"short integer\" (2 bytes), and 'l' reads one \"long integer\" (4 " "bytes) from the string." msgstr "" #: ../../faq/library.rst:510 #: ../../faq/library.rst:516 msgid "" "For data that is more regular (e.g. a homogeneous list of ints or floats), " "you can also use the :mod:`array` module." msgstr "" #: ../../faq/library.rst:515 #: ../../faq/library.rst:521 msgid "" "To read and write binary data, it is mandatory to open the file in binary " "mode (here, passing ``\"rb\"`` to :func:`open`). If you use ``\"r\"`` " "instead (the default), the file will be open in text mode and ``f.read()`` " "will return :class:`str` objects rather than :class:`bytes` objects." msgstr "" #: ../../faq/library.rst:523 #: ../../faq/library.rst:529 msgid "I can't seem to use os.read() on a pipe created with os.popen(); why?" msgstr "" #: ../../faq/library.rst:525 #: ../../faq/library.rst:531 msgid "" ":func:`os.read` is a low-level function which takes a file descriptor, a " "small integer representing the opened file. :func:`os.popen` creates a high-" Expand All @@ -574,37 +579,37 @@ msgid "" "popen`, you need to use ``p.read(n)``." msgstr "" #: ../../faq/library.rst:612 #: ../../faq/library.rst:618 msgid "How do I access the serial (RS232) port?" msgstr "" #: ../../faq/library.rst:614 #: ../../faq/library.rst:620 msgid "For Win32, OSX, Linux, BSD, Jython, IronPython:" msgstr "" #: ../../faq/library.rst:616 #: ../../faq/library.rst:622 msgid "https://pypi.org/project/pyserial/" msgstr "https://pypi.org/project/pyserial/" #: ../../faq/library.rst:618 #: ../../faq/library.rst:624 msgid "For Unix, see a Usenet post by Mitch Chapman:" msgstr "" #: ../../faq/library.rst:620 #: ../../faq/library.rst:626 msgid "https://groups.google.com/groups?selm=34A04430.CF9@ohioee.com" msgstr "https://groups.google.com/groups?selm=34A04430.CF9@ohioee.com" #: ../../faq/library.rst:624 #: ../../faq/library.rst:630 msgid "Why doesn't closing sys.stdout (stdin, stderr) really close it?" msgstr "" #: ../../faq/library.rst:626 #: ../../faq/library.rst:632 msgid "" "Python :term:`file objects <file object>` are a high-level layer of " "abstraction on low-level C file descriptors." msgstr "" #: ../../faq/library.rst:629 #: ../../faq/library.rst:635 msgid "" "For most file objects you create in Python via the built-in :func:`open` " "function, ``f.close()`` marks the Python file object as being closed from " Expand All @@ -613,120 +618,120 @@ msgid "" "``f`` becomes garbage." msgstr "" #: ../../faq/library.rst:635 #: ../../faq/library.rst:641 msgid "" "But stdin, stdout and stderr are treated specially by Python, because of the " "special status also given to them by C. Running ``sys.stdout.close()`` " "marks the Python-level file object as being closed, but does *not* close the " "associated C file descriptor." msgstr "" #: ../../faq/library.rst:640 #: ../../faq/library.rst:646 msgid "" "To close the underlying C file descriptor for one of these three, you should " "first be sure that's what you really want to do (e.g., you may confuse " "extension modules trying to do I/O). If it is, use :func:`os.close`::" msgstr "" #: ../../faq/library.rst:648 #: ../../faq/library.rst:654 msgid "Or you can use the numeric constants 0, 1 and 2, respectively." msgstr "" #: ../../faq/library.rst:652 #: ../../faq/library.rst:658 msgid "Network/Internet Programming" msgstr "" #: ../../faq/library.rst:655 #: ../../faq/library.rst:661 msgid "What WWW tools are there for Python?" msgstr "" #: ../../faq/library.rst:657 #: ../../faq/library.rst:663 msgid "" "See the chapters titled :ref:`internet` and :ref:`netdata` in the Library " "Reference Manual. Python has many modules that will help you build server-" "side and client-side web systems." msgstr "" #: ../../faq/library.rst:663 #: ../../faq/library.rst:669 msgid "" "A summary of available frameworks is maintained by Paul Boddie at https://" "wiki.python.org/moin/WebProgramming\\ ." msgstr "" #: ../../faq/library.rst:666 #: ../../faq/library.rst:672 msgid "" "Cameron Laird maintains a useful set of pages about Python web technologies " "at http://phaseit.net/claird/comp.lang.python/web_python." msgstr "" #: ../../faq/library.rst:671 #: ../../faq/library.rst:677 msgid "How can I mimic CGI form submission (METHOD=POST)?" msgstr "" #: ../../faq/library.rst:673 #: ../../faq/library.rst:679 msgid "" "I would like to retrieve web pages that are the result of POSTing a form. Is " "there existing code that would let me do this easily?" msgstr "" #: ../../faq/library.rst:676 #: ../../faq/library.rst:682 msgid "Yes. Here's a simple example that uses :mod:`urllib.request`::" msgstr "" #: ../../faq/library.rst:691 #: ../../faq/library.rst:697 msgid "" "Note that in general for percent-encoded POST operations, query strings must " "be quoted using :func:`urllib.parse.urlencode`. For example, to send " "``name=Guy Steele, Jr.``::" msgstr "" #: ../../faq/library.rst:699 #: ../../faq/library.rst:705 msgid ":ref:`urllib-howto` for extensive examples." msgstr "" #: ../../faq/library.rst:703 #: ../../faq/library.rst:709 msgid "What module should I use to help with generating HTML?" msgstr "" #: ../../faq/library.rst:707 #: ../../faq/library.rst:713 msgid "" "You can find a collection of useful links on the `Web Programming wiki page " "<https://wiki.python.org/moin/WebProgramming>`_." msgstr "" #: ../../faq/library.rst:712 #: ../../faq/library.rst:718 msgid "How do I send mail from a Python script?" msgstr "" #: ../../faq/library.rst:714 #: ../../faq/library.rst:720 msgid "Use the standard library module :mod:`smtplib`." msgstr "" #: ../../faq/library.rst:716 #: ../../faq/library.rst:722 msgid "" "Here's a very simple interactive mail sender that uses it. This method will " "work on any host that supports an SMTP listener. ::" msgstr "" #: ../../faq/library.rst:736 #: ../../faq/library.rst:742 msgid "" "A Unix-only alternative uses sendmail. The location of the sendmail program " "varies between systems; sometimes it is ``/usr/lib/sendmail``, sometimes ``/" "usr/sbin/sendmail``. The sendmail manual page will help you out. Here's " "some sample code::" msgstr "" #: ../../faq/library.rst:756 #: ../../faq/library.rst:762 msgid "How do I avoid blocking in the connect() method of a socket?" msgstr "" #: ../../faq/library.rst:758 #: ../../faq/library.rst:764 msgid "" "The :mod:`select` module is commonly used to help with asynchronous I/O on " "sockets." msgstr "" #: ../../faq/library.rst:761 #: ../../faq/library.rst:767 msgid "" "To prevent the TCP connect from blocking, you can set the socket to non-" "blocking mode. Then when you do the :meth:`socket.connect`, you will either " Expand All @@ -736,7 +741,7 @@ msgid "" "values, so you're going to have to check what's returned on your system." msgstr "" #: ../../faq/library.rst:768 #: ../../faq/library.rst:774 msgid "" "You can use the :meth:`socket.connect_ex` method to avoid creating an " "exception. It will just return the errno value. To poll, you can call :" Expand All @@ -745,102 +750,102 @@ msgid "" "select` to check if it's writable." msgstr "" #: ../../faq/library.rst:774 #: ../../faq/library.rst:780 msgid "" "The :mod:`asyncio` module provides a general purpose single-threaded and " "concurrent asynchronous library, which can be used for writing non-blocking " "network code. The third-party `Twisted <https://twistedmatrix.com/trac/>`_ " "library is a popular and feature-rich alternative." msgstr "" #: ../../faq/library.rst:782 #: ../../faq/library.rst:788 msgid "Databases" msgstr "" #: ../../faq/library.rst:785 #: ../../faq/library.rst:791 msgid "Are there any interfaces to database packages in Python?" msgstr "" #: ../../faq/library.rst:787 #: ../../faq/library.rst:793 msgid "Yes." msgstr "有的" #: ../../faq/library.rst:789 #: ../../faq/library.rst:795 msgid "" "Interfaces to disk-based hashes such as :mod:`DBM <dbm.ndbm>` and :mod:`GDBM " "<dbm.gnu>` are also included with standard Python. There is also the :mod:" "`sqlite3` module, which provides a lightweight disk-based relational " "database." msgstr "" #: ../../faq/library.rst:794 #: ../../faq/library.rst:800 msgid "" "Support for most relational databases is available. See the " "`DatabaseProgramming wiki page <https://wiki.python.org/moin/" "DatabaseProgramming>`_ for details." msgstr "" #: ../../faq/library.rst:800 #: ../../faq/library.rst:806 msgid "How do you implement persistent objects in Python?" msgstr "" #: ../../faq/library.rst:802 #: ../../faq/library.rst:808 msgid "" "The :mod:`pickle` library module solves this in a very general way (though " "you still can't store things like open files, sockets or windows), and the :" "mod:`shelve` library module uses pickle and (g)dbm to create persistent " "mappings containing arbitrary Python objects." msgstr "" #: ../../faq/library.rst:809 #: ../../faq/library.rst:815 msgid "Mathematics and Numerics" msgstr "" #: ../../faq/library.rst:812 #: ../../faq/library.rst:818 msgid "How do I generate random numbers in Python?" msgstr "" #: ../../faq/library.rst:814 #: ../../faq/library.rst:820 msgid "" "The standard module :mod:`random` implements a random number generator. " "Usage is simple::" msgstr "" #: ../../faq/library.rst:820 #: ../../faq/library.rst:826 msgid "This returns a random floating point number in the range [0, 1)." msgstr "" #: ../../faq/library.rst:822 #: ../../faq/library.rst:828 msgid "" "There are also many other specialized generators in this module, such as:" msgstr "" #: ../../faq/library.rst:824 #: ../../faq/library.rst:830 msgid "``randrange(a, b)`` chooses an integer in the range [a, b)." msgstr "" #: ../../faq/library.rst:825 #: ../../faq/library.rst:831 msgid "``uniform(a, b)`` chooses a floating point number in the range [a, b)." msgstr "" #: ../../faq/library.rst:826 #: ../../faq/library.rst:832 msgid "" "``normalvariate(mean, sdev)`` samples the normal (Gaussian) distribution." msgstr "" #: ../../faq/library.rst:828 #: ../../faq/library.rst:834 msgid "Some higher-level functions operate on sequences directly, such as:" msgstr "" #: ../../faq/library.rst:830 #: ../../faq/library.rst:836 msgid "``choice(S)`` chooses a random element from a given sequence." msgstr "" #: ../../faq/library.rst:831 #: ../../faq/library.rst:837 msgid "``shuffle(L)`` shuffles a list in-place, i.e. permutes it randomly." msgstr "" #: ../../faq/library.rst:833 #: ../../faq/library.rst:839 msgid "" "There's also a ``Random`` class you can instantiate to create independent " "multiple random number generators." Expand Down