@@ -215,16 +215,20 @@ msgid ""
215
215
"Unlike pickle, deserializing untrusted JSON does not in itself create an "
216
216
"arbitrary code execution vulnerability."
217
217
msgstr ""
218
+ "去序列化不安全的 JSON 不會產生任意程式執行的風險,但去序列化不安全的 pickle "
219
+ "會。"
218
220
219
221
#: ../../library/pickle.rst:114
220
222
msgid ""
221
223
"The :mod:`json` module: a standard library module allowing JSON "
222
224
"serialization and deserialization."
223
225
msgstr ""
226
+ ":mod:`json` module: 是標準函式庫的一部分,可讓使用者進行 JSON 的序列化與去序"
227
+ "列化。"
224
228
225
229
#: ../../library/pickle.rst:121
226
230
msgid "Data stream format"
227
- msgstr ""
231
+ msgstr "資料串流格式 "
228
232
229
233
#: ../../library/pickle.rst:126
230
234
msgid ""
@@ -234,53 +238,68 @@ msgid ""
234
238
"that non-Python programs may not be able to reconstruct pickled Python "
235
239
"objects."
236
240
msgstr ""
241
+ ":mod:`pickle` 使用的資料格式是針對 Python 而設計的。好處是他不會受到外部標準"
242
+ "(像是 JSON 或 XDR,而 XDR 無法紀錄指標共用)的限制;不過這也代表其他不是 "
243
+ "Python 的程式可能無法重建 pickle 封裝的 Python 物件。"
237
244
238
245
#: ../../library/pickle.rst:131
239
246
msgid ""
240
247
"By default, the :mod:`pickle` data format uses a relatively compact binary "
241
248
"representation. If you need optimal size characteristics, you can "
242
249
"efficiently :doc:`compress <archiving>` pickled data."
243
250
msgstr ""
251
+ "以預設設定來說,:mod:`pickle` 使用相對緊湊的二進位形式來儲存資料。如果你需要"
252
+ "盡可能地縮小檔案大小,你可以\\\\ :doc:`壓縮 <archiving>`\\\\ 封裝的資料。"
244
253
245
254
#: ../../library/pickle.rst:135
246
255
msgid ""
247
256
"The module :mod:`pickletools` contains tools for analyzing data streams "
248
257
"generated by :mod:`pickle`. :mod:`pickletools` source code has extensive "
249
258
"comments about opcodes used by pickle protocols."
250
259
msgstr ""
260
+ ":mod:`pickletools` 含有工具可分析 :mod:`pickle` 所產生的資料流。:mod:"
261
+ "`pickletools` 的源始碼詳細地記載了所有 pickle 協定的操作碼(opcode)。"
251
262
252
263
#: ../../library/pickle.rst:139
253
264
msgid ""
254
265
"There are currently 6 different protocols which can be used for pickling. "
255
266
"The higher the protocol used, the more recent the version of Python needed "
256
267
"to read the pickle produced."
257
268
msgstr ""
269
+ "截至目前為止,共有六種不同版本的協定可用於封裝 pickle。數字越大版本代表你需"
270
+ "要使用越新的 Python 版本來拆封相應的 pickle 封裝。"
258
271
259
272
#: ../../library/pickle.rst:143
260
273
msgid ""
261
274
"Protocol version 0 is the original \" human-readable\" protocol and is "
262
275
"backwards compatible with earlier versions of Python."
263
276
msgstr ""
277
+ "版本 0 的協定是最初「人類可讀」的版本,且可以向前支援早期版本的 Python。"
264
278
265
279
#: ../../library/pickle.rst:146
266
280
msgid ""
267
281
"Protocol version 1 is an old binary format which is also compatible with "
268
282
"earlier versions of Python."
269
- msgstr ""
283
+ msgstr "版本 1 的協定使用舊的二進位格式,一樣能向前支援早期版本的 Python。 "
270
284
271
285
#: ../../library/pickle.rst:149
272
286
msgid ""
273
287
"Protocol version 2 was introduced in Python 2.3. It provides much more "
274
288
"efficient pickling of :term:`new-style classes <new-style class>`. Refer "
275
289
"to :pep:`307` for information about improvements brought by protocol 2."
276
290
msgstr ""
291
+ "版本 2 的協定在 Python 2.3 中初次被引入。其可提供更高效率的 :term:`new-style "
292
+ "classes <new-style class>` 封裝過程。請參閱 :pep:`307` 以了解版本 2 帶來的改"
293
+ "進。"
277
294
278
295
#: ../../library/pickle.rst:153
279
296
msgid ""
280
297
"Protocol version 3 was added in Python 3.0. It has explicit support for :"
281
298
"class:`bytes` objects and cannot be unpickled by Python 2.x. This was the "
282
299
"default protocol in Python 3.0--3.7."
283
300
msgstr ""
301
+ "版本 3 的協定在 Python 3.0 被新增。現在能支援封裝 :class:`bytes` 的物件且無法"
302
+ "被 2.x 版本的 Python 拆封。在 3.0~3.7 的 Python 預設使用 3 版協定。"
284
303
285
304
#: ../../library/pickle.rst:157
286
305
msgid ""
@@ -289,6 +308,9 @@ msgid ""
289
308
"optimizations. It is the default protocol starting with Python 3.8. Refer "
290
309
"to :pep:`3154` for information about improvements brought by protocol 4."
291
310
msgstr ""
311
+ "版本 4 的協定在 Python 3.4 被新增。現在能支援超大物件的封裝、更多種型別的物件"
312
+ "以及針對部份資料格式的儲存進行最佳化。從 Python 3.8 起,預設使用第 4 版協定。"
313
+ "請參閱 :pep:`3154` 以了解第 4 版協定改進的細節。"
292
314
293
315
#: ../../library/pickle.rst:163
294
316
msgid ""
@@ -310,6 +332,12 @@ msgid ""
310
332
"database. The :mod:`shelve` module provides a simple interface to pickle "
311
333
"and unpickle objects on DBM-style database files."
312
334
msgstr ""
335
+ "資料序列化是一個比資料持久化更早期的概念;雖然 :mod:`pickle` 可以讀寫檔案物"
336
+ "件,但它並不處理命名持久物件的問題,也不處理對持久物件並行存取,一個更棘手的"
337
+ "問題。:mod:`pickle` 模組可以將複雜物件轉換成位元組串流,也可以將位元組串流轉"
338
+ "換回具有相同原始內部結構的物件。對這些位元組串流最明顯的處理方式大概是將它們"
339
+ "寫入檔案中,但也可能將它們透過網路傳送或儲存在一個資料庫中。:mod:`shelve` 模"
340
+ "組提供了一個簡單的介面來在 DBM 風格的資料庫檔案中進行物件的封裝和拆封的操作。"
313
341
314
342
#: ../../library/pickle.rst:181
315
343
msgid "Module Interface"
@@ -323,6 +351,10 @@ msgid ""
323
351
"de-serialization, you can create a :class:`Pickler` or an :class:`Unpickler` "
324
352
"object, respectively."
325
353
msgstr ""
354
+ "想要序列化一個物件,你只需要呼叫 :func:`dumps` 函數。而當你想要去序列化一個資"
355
+ "料流時,你只需要呼叫 :func:`loads` 即可。不過,若你希望能各自對序列化和去序列"
356
+ "化的過程中有更多的掌控度,你可以自訂一個 :class:`Pickler` 或 :class:"
357
+ "`Unpickler` 物件。"
326
358
327
359
#: ../../library/pickle.rst:188
328
360
msgid "The :mod:`pickle` module provides the following constants:"
0 commit comments