@@ -1218,6 +1218,7 @@ msgid ""
12181218"Hm. We certainly expected the last statement to print ``3 4 1 2``. What "
12191219"happened? Here are the steps of the ``rc.a, rc.b = rc.b, rc.a`` line above::"
12201220msgstr ""
1221+ "嗯。我们预想应该打印 ``3 4 1 2`` 。但是为什么呢? 这是 ``rc.a, rc.b = rc.b, rc.a`` 这行代码展开后的步骤::"
12211222
12221223#: ../../library/ctypes.rst:1161
12231224msgid ""
@@ -1227,25 +1228,28 @@ msgid ""
12271228"the contents of ``temp1``. So, the last assignment ``rc.b = temp1``, doesn't"
12281229" have the expected effect."
12291230msgstr ""
1231+ "注意 ``temp0`` 和 ``temp1`` 对象始终引用了对象 ``rc`` 的内容。然后执行 ``rc.a = temp0`` 会把 "
1232+ "``temp0`` 的内容拷贝到 ``rc`` 的空间。这也改变了 ``temp1`` 的内容。最终导致赋值语句 ``rc.b = temp1`` "
1233+ "没有产生预想的效果。 "
12301234
12311235#: ../../library/ctypes.rst:1167
12321236msgid ""
12331237"Keep in mind that retrieving sub-objects from Structure, Unions, and Arrays "
12341238"doesn't *copy* the sub-object, instead it retrieves a wrapper object "
12351239"accessing the root-object's underlying buffer."
1236- msgstr ""
1240+ msgstr "记住,访问被包含在结构体、联合、数组中的对象并不会将其 *复制* 出来,而是得到了一个代理对象,它是对根对象的内部内容的一层包装。 "
12371241
12381242#: ../../library/ctypes.rst:1171
12391243msgid ""
12401244"Another example that may behave differently from what one would expect is "
12411245"this::"
1242- msgstr ""
1246+ msgstr "下面是另一个可能和预期有偏差的例子:: "
12431247
12441248#: ../../library/ctypes.rst:1183
12451249msgid ""
12461250"Objects instantiated from :class:`c_char_p` can only have their value set to"
12471251" bytes or integers."
1248- msgstr ""
1252+ msgstr "使用 :class:`c_char_p` 实例化的对象只能将其值设置为 bytes 或者整数。 "
12491253
12501254#: ../../library/ctypes.rst:1186
12511255msgid ""
@@ -1255,16 +1259,18 @@ msgid ""
12551259"object itself, instead the ``contents`` of the object is stored. Accessing "
12561260"the contents again constructs a new Python object each time!"
12571261msgstr ""
1262+ "为什么这里打印了 ``False`` ? ctypes 实例是一些内存块加上一些用于访问这些内存块的 :term:`descriptor` 组成。将 "
1263+ "Python 对象存储在内存块并不会存储对象本身,而是存储了对象的 ``内容`` 。每次访问对象的内容都会构造一个新的 Python 对象。"
12581264
12591265#: ../../library/ctypes.rst:1196
12601266msgid "Variable-sized data types"
1261- msgstr ""
1267+ msgstr "变长数据类型 "
12621268
12631269#: ../../library/ctypes.rst:1198
12641270msgid ""
12651271":mod:`ctypes` provides some support for variable-sized arrays and "
12661272"structures."
1267- msgstr ""
1273+ msgstr ":mod:`ctypes` 对变长数组和结构体提供了一些支持 。 "
12681274
12691275#: ../../library/ctypes.rst:1200
12701276msgid ""
@@ -1274,28 +1280,33 @@ msgid ""
12741280"cannot be made smaller than the natural memory block specified by the "
12751281"objects type, a :exc:`ValueError` is raised if this is tried::"
12761282msgstr ""
1283+ " :func:`resize` 函数可以用于改变已有的 ctypes "
1284+ "对象内存缓冲区大小。此函数第一个参数是ctypes对象,第二个参数是要求调整后的大小,单位是字节。不能使存储块小于对象的原有大小,否则抛出 "
1285+ ":exc:`ValueError` 异常。"
12771286
12781287#: ../../library/ctypes.rst:1220
12791288msgid ""
12801289"This is nice and fine, but how would one access the additional elements "
12811290"contained in this array? Since the type still only knows about 4 elements, "
12821291"we get errors accessing other elements::"
1283- msgstr ""
1292+ msgstr "这非常好,但是要怎么访问数组中额外的元素呢?因为数组类型已经定义包含4个元素,women访问新增元素会产生以下错误:: "
12841293
12851294#: ../../library/ctypes.rst:1232
12861295msgid ""
12871296"Another way to use variable-sized data types with :mod:`ctypes` is to use "
12881297"the dynamic nature of Python, and (re-)define the data type after the "
12891298"required size is already known, on a case by case basis."
12901299msgstr ""
1300+ "使用 :mod:`ctypes` 访问变长数据类型的一个可行方法是利用 Python "
1301+ "的动态特性,根据具体情况,在知道这个数据的大小后,(重新)指定这个数据的类型。"
12911302
12921303#: ../../library/ctypes.rst:1240
12931304msgid "ctypes reference"
1294- msgstr ""
1305+ msgstr "ctypes 参考手册 "
12951306
12961307#: ../../library/ctypes.rst:1246
12971308msgid "Finding shared libraries"
1298- msgstr ""
1309+ msgstr "寻找动态链接库 "
12991310
13001311#: ../../library/ctypes.rst:1248
13011312msgid ""
0 commit comments