@@ -36,6 +36,10 @@ msgid ""
36
36
"connections), or data transfer between the Python application and the C "
37
37
"layer."
38
38
msgstr ""
39
+ "此模組可在 Python 數值與以 Python :class:`bytes` 物件表示的 C 結構之間進行轉換。\\ "
40
+ "簡潔的\\ :ref:`格式字串 <struct-format-strings>` 描述了與 Python 數值之間預期的轉換。\\ "
41
+ "此模組的函式和物件可用於兩種截然不同的應用:與外部來源(檔案或網路連線)的資料交換,\\ "
42
+ "或是 Python 應用程式與 C 層之間的資料傳輸。"
39
43
40
44
#: ../../library/struct.rst:29
41
45
msgid ""
@@ -48,6 +52,10 @@ msgid ""
48
52
"for defining byte ordering and padding between elements. See :ref:`struct-"
49
53
"alignment` for details."
50
54
msgstr ""
55
+ "當未給定前綴字元時,原生模式為預設模式。它會根據建構 Python 直譯器的平台和編譯器來\\ "
56
+ "打包或解包資料。打包給定 C 結構的結果包含填充位元組,以維持相關 C 型別的正確對齊;\\ "
57
+ "同樣地,解包時也會考量對齊。相反地,當在外部來源之間傳輸資料時,程式設計師需負責定義\\ "
58
+ "位元組順序和元素之間的填充。詳情請參見\\ :ref:`struct-alignment`。"
51
59
52
60
#: ../../library/struct.rst:39
53
61
msgid ""
@@ -59,6 +67,11 @@ msgid ""
59
67
"of bytes implement the buffer protocol, so that they can be read/filled "
60
68
"without additional copying from a :class:`bytes` object."
61
69
msgstr ""
70
+ "一些\\ :mod:`struct` 函式(和 :class:`Struct` 的方法)接受一個 *buffer* 引數。\\ "
71
+ "這是指實作\\ :ref:`bufferobjects` 並提供可讀或可讀寫緩衝區的物件。最常用於此目的的\\ "
72
+ "型別是\\ :class:`bytes` 和\\ :class:`bytearray`,但許多其他可以視為位元組陣列的\\ "
73
+ "型別都實作了緩衝區協議,因此它們可以從\\ :class:`bytes` 物件讀取或填入資料而無需\\ "
74
+ "額外的複製。"
62
75
63
76
#: ../../library/struct.rst:48
64
77
msgid "Functions and Exceptions"
@@ -73,20 +86,25 @@ msgid ""
73
86
"Exception raised on various occasions; argument is a string describing what "
74
87
"is wrong."
75
88
msgstr ""
89
+ "在各種情況下觸發的例外;引數是一個描述錯誤內容的字串。"
76
90
77
91
#: ../../library/struct.rst:61
78
92
msgid ""
79
93
"Return a bytes object containing the values *v1*, *v2*, ... packed according "
80
94
"to the format string *format*. The arguments must match the values required "
81
95
"by the format exactly."
82
96
msgstr ""
97
+ "回傳一個包含依照格式字串 *format* 打包的數值 *v1*、*v2*、... 的 bytes 物件。\\ "
98
+ "引數必須完全符合格式所需的數值。"
83
99
84
100
#: ../../library/struct.rst:68
85
101
msgid ""
86
102
"Pack the values *v1*, *v2*, ... according to the format string *format* and "
87
103
"write the packed bytes into the writable buffer *buffer* starting at "
88
104
"position *offset*. Note that *offset* is a required argument."
89
105
msgstr ""
106
+ "依照格式字串 *format* 打包數值 *v1*、*v2*、...,並將打包後的位元組寫入可寫緩衝區 "
107
+ "*buffer* 中從位置 *offset* 開始的地方。請注意 *offset* 是必要的引數。"
90
108
91
109
#: ../../library/struct.rst:75
92
110
msgid ""
@@ -95,6 +113,9 @@ msgid ""
95
113
"contains exactly one item. The buffer's size in bytes must match the size "
96
114
"required by the format, as reflected by :func:`calcsize`."
97
115
msgstr ""
116
+ "根據格式字串 *format* 從緩衝區 *buffer*(推測是由 ``pack(format, ...)`` 打包的)\\ "
117
+ "解包。結果是一個元組,即使它只包含一個項目。緩衝區的位元組大小必須符合格式所需的\\ "
118
+ "大小,如\\ :func:`calcsize` 所示。"
98
119
99
120
#: ../../library/struct.rst:83
100
121
msgid ""
@@ -103,6 +124,9 @@ msgid ""
103
124
"item. The buffer's size in bytes, starting at position *offset*, must be at "
104
125
"least the size required by the format, as reflected by :func:`calcsize`."
105
126
msgstr ""
127
+ "根據格式字串 *format* 從 *buffer* 的位置 *offset* 開始解包。結果是一個元組,\\ "
128
+ "即使它只包含一個項目。緩衝區從位置 *offset* 開始的位元組大小,必須至少達到\\ "
129
+ "格式所需的大小,如\\ :func:`calcsize` 所示。"
106
130
107
131
#: ../../library/struct.rst:91
108
132
msgid ""
@@ -112,20 +136,25 @@ msgid ""
112
136
"buffer's size in bytes must be a multiple of the size required by the "
113
137
"format, as reflected by :func:`calcsize`."
114
138
msgstr ""
139
+ "根據格式字串 *format* 迭代地從緩衝區 *buffer* 解包。此函式回傳一個迭代器,\\ "
140
+ "它會從緩衝區讀取等大小的區塊,直到消耗完所有內容。緩衝區的位元組大小必須是\\ "
141
+ "格式所需大小的倍數,如\\ :func:`calcsize` 所示。"
115
142
116
143
#: ../../library/struct.rst:97
117
144
msgid "Each iteration yields a tuple as specified by the format string."
118
- msgstr ""
145
+ msgstr "每次迭代都會產出由格式字串指定的元組。 "
119
146
120
147
#: ../../library/struct.rst:104
121
148
msgid ""
122
149
"Return the size of the struct (and hence of the bytes object produced by "
123
150
"``pack(format, ...)``) corresponding to the format string *format*."
124
151
msgstr ""
152
+ "回傳對應於格式字串 *format* 的結構大小(因此也是 ``pack(format, ...)`` \\ "
153
+ "所產生的 bytes 物件的大小)。"
125
154
126
155
#: ../../library/struct.rst:111
127
156
msgid "Format Strings"
128
- msgstr ""
157
+ msgstr "格式字串 "
129
158
130
159
#: ../../library/struct.rst:113
131
160
msgid ""
@@ -137,10 +166,14 @@ msgid ""
137
166
"which describes the overall properties of the data and one or more format "
138
167
"characters which describe the actual data values and padding."
139
168
msgstr ""
169
+ "格式字串描述了打包和解包資料時的資料配置。它們由\\ :ref:`格式字元<format-characters>` \\ "
170
+ "組成,這些字元指定了要打包或解包的資料型別。此外,特殊字元控制\\ :ref:`位元組順序、\\ "
171
+ "大小和對齊<struct-alignment>`。每個格式字串由一個可選的前綴字元組成,描述資料的\\ "
172
+ "整體屬性,以及一個或多個描述實際資料值和填充的格式字元。"
140
173
141
174
#: ../../library/struct.rst:125
142
175
msgid "Byte Order, Size, and Alignment"
143
- msgstr ""
176
+ msgstr "位元組順序、大小和對齊 "
144
177
145
178
#: ../../library/struct.rst:127
146
179
msgid ""
@@ -151,6 +184,9 @@ msgid ""
151
184
"corresponding C struct. Whether to use native byte ordering and padding or "
152
185
"standard formats depends on the application."
153
186
msgstr ""
187
+ "預設情況下,C 型別以機器的原生格式和位元組順序表示,並在必要時透過跳過填充位元組\\ "
188
+ "來正確對齊(根據 C 編譯器所使用的規則)。選擇此行為使得打包結構的位元組完全對應於\\ "
189
+ "相對應 C 結構的記憶體配置。是否使用原生位元組順序和填充或標準格式取決於應用程式。"
154
190
155
191
#: ../../library/struct.rst:143
156
192
msgid ""
0 commit comments