@@ -624,19 +624,22 @@ msgid ""
624624"return types can be specified by setting the :attr:`restype` attribute of "
625625"the function object."
626626msgstr ""
627+ "默认情况下都会假定函数返回C :c:type:`int` 类型。其他返回类型可以通过设置函数对象的 :attr:`restype` 属性来指定。"
627628
628629#: ../../library/ctypes.rst:451
629630msgid ""
630631"Here is a more advanced example, it uses the ``strchr`` function, which "
631632"expects a string pointer and a char, and returns a pointer to a string::"
632- msgstr ""
633+ msgstr "这是个更高级的例子,它调用了 ``strchr`` 函数,这个函数接收一个字符串指针以及一个字符作为参数,返回另一个字符串指针。 "
633634
634635#: ../../library/ctypes.rst:464
635636msgid ""
636637"If you want to avoid the ``ord(\" x\" )`` calls above, you can set the "
637638":attr:`argtypes` attribute, and the second argument will be converted from a"
638639" single character Python bytes object into a C char::"
639640msgstr ""
641+ "如果希望避免上述的 ``ord(\" x\" )`` 调用,可以设置 :attr:`argtypes` 属性,第二个参数就会将单字符的 Python "
642+ "二进制字符对象转换为 C 字符::"
640643
641644#: ../../library/ctypes.rst:482
642645msgid ""
@@ -647,6 +650,8 @@ msgid ""
647650"function call. This is useful to check for error return values and "
648651"automatically raise an exception::"
649652msgstr ""
653+ "如果外部函数返回了一个整数,你也可以使用要给可调用的 Python 对象(比如函数或者类)作为 :attr:`restype` 属性的值。将会以 C "
654+ "函数返回的 *整数* 对象作为参数调用这个可调用对象,执行后的结果作为最终函数返回值。这在错误返回值校验和自动抛出异常等方面比较有用。"
650655
651656#: ../../library/ctypes.rst:505
652657msgid ""
@@ -655,17 +660,19 @@ msgid ""
655660"exception. ``WinError`` takes an optional error code parameter, if no one is"
656661" used, it calls :func:`GetLastError` to retrieve it."
657662msgstr ""
663+ "``WinError`` 函数可以调用 Windows 的 ``FormatMessage()`` API 获取错误码的字符串说明,然后 *返回* "
664+ "一个异常。 ``WinError`` 接收一个可选的错误码作为参数,如果没有的话,它将调用 :func:`GetLastError` 获取错误码。"
658665
659666#: ../../library/ctypes.rst:510
660667msgid ""
661668"Please note that a much more powerful error checking mechanism is available "
662669"through the :attr:`errcheck` attribute; see the reference manual for "
663670"details."
664- msgstr ""
671+ msgstr "请注意,使用 :attr:`errcheck` 属性可以实现更强大的错误检查手段;详情请见参考手册。 "
665672
666673#: ../../library/ctypes.rst:517
667674msgid "Passing pointers (or: passing parameters by reference)"
668- msgstr ""
675+ msgstr "传递指针(或者传递引用) "
669676
670677#: ../../library/ctypes.rst:519
671678msgid ""
@@ -674,6 +681,8 @@ msgid ""
674681"large to be passed by value. This is also known as *passing parameters by "
675682"reference*."
676683msgstr ""
684+ "有时候 C 函数接口可能由于要往某个地址写入值,或者数据太大不适合作为值传递,从而希望接收一个 *指针* 作为数据参数类型。这和 *传递参数引用* "
685+ "类似。"
677686
678687#: ../../library/ctypes.rst:523
679688msgid ""
0 commit comments