Skip to content

Commit ff086ac

Browse files
Copilotmattwang44
andcommitted
Translate core struct module descriptions and functions
Co-authored-by: mattwang44 <24987826+mattwang44@users.noreply.github.com>
1 parent 0c1d5d0 commit ff086ac

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

library/struct.po

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ msgid ""
3636
"connections), or data transfer between the Python application and the C "
3737
"layer."
3838
msgstr ""
39+
"此模組可在 Python 數值與以 Python :class:`bytes` 物件表示的 C 結構之間進行轉換。\\"
40+
"簡潔的\\ :ref:`格式字串 <struct-format-strings>` 描述了與 Python 數值之間預期的轉換。\\"
41+
"此模組的函式和物件可用於兩種截然不同的應用:與外部來源(檔案或網路連線)的資料交換,\\"
42+
"或是 Python 應用程式與 C 層之間的資料傳輸。"
3943

4044
#: ../../library/struct.rst:29
4145
msgid ""
@@ -48,6 +52,10 @@ msgid ""
4852
"for defining byte ordering and padding between elements. See :ref:`struct-"
4953
"alignment` for details."
5054
msgstr ""
55+
"當未給定前綴字元時,原生模式為預設模式。它會根據建構 Python 直譯器的平台和編譯器來\\"
56+
"打包或解包資料。打包給定 C 結構的結果包含填充位元組,以維持相關 C 型別的正確對齊;\\"
57+
"同樣地,解包時也會考量對齊。相反地,當在外部來源之間傳輸資料時,程式設計師需負責定義\\"
58+
"位元組順序和元素之間的填充。詳情請參見\\ :ref:`struct-alignment`。"
5159

5260
#: ../../library/struct.rst:39
5361
msgid ""
@@ -59,6 +67,11 @@ msgid ""
5967
"of bytes implement the buffer protocol, so that they can be read/filled "
6068
"without additional copying from a :class:`bytes` object."
6169
msgstr ""
70+
"一些\\ :mod:`struct` 函式(和 :class:`Struct` 的方法)接受一個 *buffer* 引數。\\"
71+
"這是指實作\\ :ref:`bufferobjects` 並提供可讀或可讀寫緩衝區的物件。最常用於此目的的\\"
72+
"型別是\\ :class:`bytes` 和\\ :class:`bytearray`,但許多其他可以視為位元組陣列的\\"
73+
"型別都實作了緩衝區協議,因此它們可以從\\ :class:`bytes` 物件讀取或填入資料而無需\\"
74+
"額外的複製。"
6275

6376
#: ../../library/struct.rst:48
6477
msgid "Functions and Exceptions"
@@ -73,20 +86,25 @@ msgid ""
7386
"Exception raised on various occasions; argument is a string describing what "
7487
"is wrong."
7588
msgstr ""
89+
"在各種情況下觸發的例外;引數是一個描述錯誤內容的字串。"
7690

7791
#: ../../library/struct.rst:61
7892
msgid ""
7993
"Return a bytes object containing the values *v1*, *v2*, ... packed according "
8094
"to the format string *format*. The arguments must match the values required "
8195
"by the format exactly."
8296
msgstr ""
97+
"回傳一個包含依照格式字串 *format* 打包的數值 *v1*、*v2*、... 的 bytes 物件。\\"
98+
"引數必須完全符合格式所需的數值。"
8399

84100
#: ../../library/struct.rst:68
85101
msgid ""
86102
"Pack the values *v1*, *v2*, ... according to the format string *format* and "
87103
"write the packed bytes into the writable buffer *buffer* starting at "
88104
"position *offset*. Note that *offset* is a required argument."
89105
msgstr ""
106+
"依照格式字串 *format* 打包數值 *v1*、*v2*、...,並將打包後的位元組寫入可寫緩衝區 "
107+
"*buffer* 中從位置 *offset* 開始的地方。請注意 *offset* 是必要的引數。"
90108

91109
#: ../../library/struct.rst:75
92110
msgid ""
@@ -95,6 +113,9 @@ msgid ""
95113
"contains exactly one item. The buffer's size in bytes must match the size "
96114
"required by the format, as reflected by :func:`calcsize`."
97115
msgstr ""
116+
"根據格式字串 *format* 從緩衝區 *buffer*(推測是由 ``pack(format, ...)`` 打包的)\\"
117+
"解包。結果是一個元組,即使它只包含一個項目。緩衝區的位元組大小必須符合格式所需的\\"
118+
"大小,如\\ :func:`calcsize` 所示。"
98119

99120
#: ../../library/struct.rst:83
100121
msgid ""
@@ -103,6 +124,9 @@ msgid ""
103124
"item. The buffer's size in bytes, starting at position *offset*, must be at "
104125
"least the size required by the format, as reflected by :func:`calcsize`."
105126
msgstr ""
127+
"根據格式字串 *format* 從 *buffer* 的位置 *offset* 開始解包。結果是一個元組,\\"
128+
"即使它只包含一個項目。緩衝區從位置 *offset* 開始的位元組大小,必須至少達到\\"
129+
"格式所需的大小,如\\ :func:`calcsize` 所示。"
106130

107131
#: ../../library/struct.rst:91
108132
msgid ""
@@ -112,20 +136,25 @@ msgid ""
112136
"buffer's size in bytes must be a multiple of the size required by the "
113137
"format, as reflected by :func:`calcsize`."
114138
msgstr ""
139+
"根據格式字串 *format* 迭代地從緩衝區 *buffer* 解包。此函式回傳一個迭代器,\\"
140+
"它會從緩衝區讀取等大小的區塊,直到消耗完所有內容。緩衝區的位元組大小必須是\\"
141+
"格式所需大小的倍數,如\\ :func:`calcsize` 所示。"
115142

116143
#: ../../library/struct.rst:97
117144
msgid "Each iteration yields a tuple as specified by the format string."
118-
msgstr ""
145+
msgstr "每次迭代都會產出由格式字串指定的元組。"
119146

120147
#: ../../library/struct.rst:104
121148
msgid ""
122149
"Return the size of the struct (and hence of the bytes object produced by "
123150
"``pack(format, ...)``) corresponding to the format string *format*."
124151
msgstr ""
152+
"回傳對應於格式字串 *format* 的結構大小(因此也是 ``pack(format, ...)`` \\"
153+
"所產生的 bytes 物件的大小)。"
125154

126155
#: ../../library/struct.rst:111
127156
msgid "Format Strings"
128-
msgstr ""
157+
msgstr "格式字串"
129158

130159
#: ../../library/struct.rst:113
131160
msgid ""
@@ -137,10 +166,14 @@ msgid ""
137166
"which describes the overall properties of the data and one or more format "
138167
"characters which describe the actual data values and padding."
139168
msgstr ""
169+
"格式字串描述了打包和解包資料時的資料配置。它們由\\ :ref:`格式字元<format-characters>` \\"
170+
"組成,這些字元指定了要打包或解包的資料型別。此外,特殊字元控制\\ :ref:`位元組順序、\\"
171+
"大小和對齊<struct-alignment>`。每個格式字串由一個可選的前綴字元組成,描述資料的\\"
172+
"整體屬性,以及一個或多個描述實際資料值和填充的格式字元。"
140173

141174
#: ../../library/struct.rst:125
142175
msgid "Byte Order, Size, and Alignment"
143-
msgstr ""
176+
msgstr "位元組順序、大小和對齊"
144177

145178
#: ../../library/struct.rst:127
146179
msgid ""
@@ -151,6 +184,9 @@ msgid ""
151184
"corresponding C struct. Whether to use native byte ordering and padding or "
152185
"standard formats depends on the application."
153186
msgstr ""
187+
"預設情況下,C 型別以機器的原生格式和位元組順序表示,並在必要時透過跳過填充位元組\\"
188+
"來正確對齊(根據 C 編譯器所使用的規則)。選擇此行為使得打包結構的位元組完全對應於\\"
189+
"相對應 C 結構的記憶體配置。是否使用原生位元組順序和填充或標準格式取決於應用程式。"
154190

155191
#: ../../library/struct.rst:143
156192
msgid ""

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy