@@ -754,9 +754,9 @@ msgstr ""
754
754
"``'p'`` 格式字元編碼一個「Pascal 字串」,意思是儲存在 *固定位元組數* 中的短變長\\ "
755
755
"字串,由計數指定。儲存的第一個位元組是字串的長度,或 255,取較小者。字串的位元組\\ "
756
756
"在其後。如果傳遞給\\ :func:`pack` 的字串太長(長於計數減 1),則只儲存字串的前 \\ "
757
- "``count-1`` 個位元組。如果字串短於 ``count-1``,則用空位元組填充,使得總共使用\\ "
758
- "恰好 count 個位元組。請注意,對於\\ :func:`unpack`,``'p'`` 格式字元消耗 ``count`` \\ "
759
- "個位元組,但回傳的字串永遠不能包含超過 255 個位元組。"
757
+ "``count-1`` 個位元組。如果字串短於 ``count-1``\ ,則用空位元組填充,使得總共使用\\ "
758
+ "恰好 count 個位元組。請注意,對於\\ :func:`unpack`,\\ ``'p'`` 格式字元消耗 \\ "
759
+ "``count`` 個位元組,但回傳的字串永遠不能包含超過 255 個位元組。"
760
760
761
761
#: ../../library/struct.rst:339
762
762
msgid ""
@@ -772,18 +772,28 @@ msgid ""
772
772
"number of bytes. As a special case, ``'0s'`` means a single, empty string "
773
773
"(while ``'0c'`` means 0 characters)."
774
774
msgstr ""
775
+ "對於 ``'s'`` 格式字元,計數被解釋為位元組的長度,而不是像其他格式字元那樣的重複\\ "
776
+ "次數;例如,``'10s'`` 表示一個 10 位元組字串,對應於單一 Python 位元組字串,\\ "
777
+ "而 ``'10c'`` 表示 10 個獨立的單位元組字元元素(例如,\\ ``cccccccccc``\ ),對應於\\ "
778
+ "十個不同的 Python 位元組物件。(請參見\\ :ref:`struct-examples` 以了解具體差異\\ "
779
+ "的示範。)如果未給定計數,則預設為 1。打包時,會適當地截斷或用空位元組填充字串\\ "
780
+ "以使其適合。解包時,結果位元組物件總是恰好具有指定的位元組數。作為特殊情況,\\ "
781
+ "``'0s'`` 表示單一空字串(而 ``'0c'`` 表示 0 個字元)。"
775
782
776
783
#: ../../library/struct.rst:352
777
784
msgid ""
778
785
"A format character may be preceded by an integral repeat count. For "
779
786
"example, the format string ``'4h'`` means exactly the same as ``'hhhh'``."
780
787
msgstr ""
788
+ "格式字元前面可以加上整數重複次數。例如,格式字串 ``'4h'`` 與 ``'hhhh'`` \\ "
789
+ "意思完全相同。"
781
790
782
791
#: ../../library/struct.rst:355
783
792
msgid ""
784
793
"Whitespace characters between formats are ignored; a count and its format "
785
794
"must not contain whitespace though."
786
795
msgstr ""
796
+ "格式之間的空白字元會被忽略;但是計數和其格式不能包含空白字元。"
787
797
788
798
#: ../../library/struct.rst:358
789
799
msgid ""
@@ -792,12 +802,17 @@ msgid ""
792
802
"``'Q'``), if ``x`` is outside the valid range for that format "
793
803
"then :exc:`struct.error` is raised."
794
804
msgstr ""
805
+ "當使用整數格式之一(``'b'``、``'B'``、``'h'``、``'H'``、``'i'``、``'I'``、\\ "
806
+ "``'l'``、``'L'``、``'q'``、``'Q'``)打包數值 ``x`` 時,如果 ``x`` 超出該\\ "
807
+ "格式的有效範圍,則會觸發\\ :exc:`struct.error`。"
795
808
796
809
#: ../../library/struct.rst:363
797
810
msgid ""
798
811
"Previously, some of the integer formats wrapped out-of-range values and "
799
812
"raised :exc:`DeprecationWarning` instead of :exc:`struct.error`."
800
813
msgstr ""
814
+ "以前,一些整數格式會環繞超出範圍的數值並觸發\\ :exc:`DeprecationWarning` \\ "
815
+ "而不是\\ :exc:`struct.error`。"
801
816
802
817
#: ../../library/struct.rst:369
803
818
msgid ""
@@ -806,6 +821,9 @@ msgid ""
806
821
"used. Either 0 or 1 in the native or standard bool representation will be "
807
822
"packed, and any non-zero value will be ``True`` when unpacking."
808
823
msgstr ""
824
+ "對於 ``'?'`` 格式字元,回傳值是\\ :const:`True` 或\\ :const:`False`。打包時,\\ "
825
+ "使用引數物件的真值。原生或標準布林值表示法中的 0 或 1 將被打包,解包時任何\\ "
826
+ "非零值都將為 ``True``。"
809
827
810
828
#: ../../library/struct.rst:379
811
829
msgid "Examples"
@@ -817,12 +835,15 @@ msgid ""
817
835
"of any prefix character) may not match what the reader's machine produces as "
818
836
"that depends on the platform and compiler."
819
837
msgstr ""
838
+ "原生位元組順序範例(由 ``'@'`` 格式前綴或缺少任何前綴字元指定)可能與讀者機器\\ "
839
+ "產生的結果不符,因為這取決於平台和編譯器。"
820
840
821
841
#: ../../library/struct.rst:387
822
842
msgid ""
823
843
"Pack and unpack integers of three different sizes, using big endian "
824
844
"ordering::"
825
845
msgstr ""
846
+ "使用大端序打包和解包三種不同大小的整數: ::"
826
847
827
848
#: ../../library/struct.rst:390
828
849
msgid ""
@@ -844,7 +865,7 @@ msgstr ""
844
865
845
866
#: ../../library/struct.rst:398
846
867
msgid "Attempt to pack an integer which is too large for the defined field::"
847
- msgstr ""
868
+ msgstr "嘗試打包對於定義欄位來說太大的整數: :: "
848
869
849
870
#: ../../library/struct.rst:400
850
871
msgid ""
@@ -861,7 +882,7 @@ msgstr ""
861
882
#: ../../library/struct.rst:405
862
883
msgid ""
863
884
"Demonstrate the difference between ``'s'`` and ``'c'`` format characters::"
864
- msgstr ""
885
+ msgstr "示範 ``'s'`` 和 ``'c'`` 格式字元之間的差異: :: "
865
886
866
887
#: ../../library/struct.rst:408
867
888
msgid ""
@@ -880,6 +901,7 @@ msgid ""
880
901
"Unpacked fields can be named by assigning them to variables or by wrapping "
881
902
"the result in a named tuple::"
882
903
msgstr ""
904
+ "解包的欄位可以透過將其指派給變數或將結果包裝在具名元組中來命名: ::"
883
905
884
906
#: ../../library/struct.rst:416
885
907
msgid ""
@@ -908,6 +930,10 @@ msgid ""
908
930
"integer on a four-byte boundary. In this example, the output was produced on "
909
931
"a little endian machine::"
910
932
msgstr ""
933
+ "在原生模式下,格式字元的順序可能會影響大小,因為填充是隱式的。在標準模式下,\\ "
934
+ "使用者負責插入任何所需的填充。請注意下面第一個 ``pack`` 呼叫中,在打包的 ``'#'`` \\ "
935
+ "之後加入了三個 NUL 位元組,以將後續整數對齊到四位元組邊界。在此範例中,輸出是在\\ "
936
+ "小端序機器上產生的: ::"
911
937
912
938
#: ../../library/struct.rst:432
913
939
msgid ""
@@ -934,6 +960,8 @@ msgid ""
934
960
"The following format ``'llh0l'`` results in two pad bytes being added at the "
935
961
"end, assuming the platform's longs are aligned on 4-byte boundaries::"
936
962
msgstr ""
963
+ "假設平台的 long 對齊到 4 位元組邊界,以下格式 ``'llh0l'`` 會在結尾加入兩個\\ "
964
+ "填充位元組: ::"
937
965
938
966
#: ../../library/struct.rst:444
939
967
msgid ""
@@ -949,27 +977,27 @@ msgstr ":mod:`array` 模組"
949
977
950
978
#: ../../library/struct.rst:451
951
979
msgid "Packed binary storage of homogeneous data."
952
- msgstr ""
980
+ msgstr "同質資料的打包二進位儲存。 "
953
981
954
982
#: ../../library/struct.rst:453
955
983
msgid "Module :mod:`json`"
956
984
msgstr ":mod:`json` 模組"
957
985
958
986
#: ../../library/struct.rst:454
959
987
msgid "JSON encoder and decoder."
960
- msgstr ""
988
+ msgstr "JSON 編碼器和解碼器。 "
961
989
962
990
#: ../../library/struct.rst:456
963
991
msgid "Module :mod:`pickle`"
964
992
msgstr ":mod:`pickle` 模組"
965
993
966
994
#: ../../library/struct.rst:457
967
995
msgid "Python object serialization."
968
- msgstr ""
996
+ msgstr "Python 物件序列化。 "
969
997
970
998
#: ../../library/struct.rst:463
971
999
msgid "Applications"
972
- msgstr ""
1000
+ msgstr "應用 "
973
1001
974
1002
#: ../../library/struct.rst:465
975
1003
msgid ""
@@ -980,10 +1008,14 @@ msgid ""
980
1008
"layout (:ref:`standard formats<struct-standard-formats>`). Generally "
981
1009
"speaking, the format strings constructed for these two domains are distinct."
982
1010
msgstr ""
1011
+ ":mod:`struct` 模組有兩個主要應用:在應用程式內或使用相同編譯器編譯的另一個應用\\ "
1012
+ "程式之間進行 Python 和 C 程式碼的資料交換(\\ :ref:`原生格式<struct-native-formats>`),\\ "
1013
+ "以及使用約定資料配置的應用程式之間的資料交換(\\ :ref:`標準格式<struct-standard-formats>`)。\\ "
1014
+ "一般來說,為這兩個領域構造的格式字串是不同的。"
983
1015
984
1016
#: ../../library/struct.rst:476
985
1017
msgid "Native Formats"
986
- msgstr ""
1018
+ msgstr "原生格式 "
987
1019
988
1020
#: ../../library/struct.rst:478
989
1021
msgid ""
@@ -995,11 +1027,15 @@ msgid ""
995
1027
"format string to round up to the correct byte boundary for proper alignment "
996
1028
"of consecutive chunks of data."
997
1029
msgstr ""
1030
+ "當構造模擬原生配置的格式字串時,編譯器和機器架構決定位元組順序和填充。在這種\\ "
1031
+ "情況下,應該使用 ``@`` 格式字元來指定原生位元組順序和資料大小。內部填充位元組\\ "
1032
+ "通常會自動插入。可能需要在格式字串的結尾使用零重複格式代碼來向上舍入到正確的\\ "
1033
+ "位元組邊界,以便正確對齊連續的資料區塊。"
998
1034
999
1035
#: ../../library/struct.rst:486
1000
1036
msgid ""
1001
1037
"Consider these two simple examples (on a 64-bit, little-endian machine)::"
1002
- msgstr ""
1038
+ msgstr "考慮這兩個簡單範例(在 64 位元小端序機器上): :: "
1003
1039
1004
1040
#: ../../library/struct.rst:489
1005
1041
msgid ""
@@ -1019,6 +1055,8 @@ msgid ""
1019
1055
"string without the use of extra padding. A zero-repeat format code solves "
1020
1056
"that problem::"
1021
1057
msgstr ""
1058
+ "在第二個格式字串的結尾,如果不使用額外填充,資料不會填充到 8 位元組邊界。\\ "
1059
+ "零重複格式代碼解決了這個問題: ::"
1022
1060
1023
1061
#: ../../library/struct.rst:498
1024
1062
msgid ""
@@ -1033,16 +1071,19 @@ msgid ""
1033
1071
"The ``'x'`` format code can be used to specify the repeat, but for native "
1034
1072
"formats it is better to use a zero-repeat format like ``'0l'``."
1035
1073
msgstr ""
1074
+ "``'x'`` 格式代碼可以用來指定重複,但對於原生格式,最好使用像 ``'0l'`` 這樣的\\ "
1075
+ "零重複格式。"
1036
1076
1037
1077
#: ../../library/struct.rst:504
1038
1078
msgid ""
1039
1079
"By default, native byte ordering and alignment is used, but it is better to "
1040
1080
"be explicit and use the ``'@'`` prefix character."
1041
1081
msgstr ""
1082
+ "預設使用原生位元組順序和對齊,但最好明確使用 ``'@'`` 前綴字元。"
1042
1083
1043
1084
#: ../../library/struct.rst:511
1044
1085
msgid "Standard Formats"
1045
- msgstr ""
1086
+ msgstr "標準格式 "
1046
1087
1047
1088
#: ../../library/struct.rst:513
1048
1089
msgid ""
@@ -1057,6 +1098,12 @@ msgid ""
1057
1098
"must explicitly add ``'x'`` pad bytes where needed. Revisiting the examples "
1058
1099
"from the previous section, we have::"
1059
1100
msgstr ""
1101
+ "當與您的程序之外的網路或儲存等交換資料時,要精確。指定確切的位元組順序、大小\\ "
1102
+ "和對齊。不要假設它們與特定機器的原生順序匹配。例如,網路位元組順序是大端序,\\ "
1103
+ "而許多流行的 CPU 是小端序。透過明確定義這一點,使用者無需關心其程式碼運行的\\ "
1104
+ "平台細節。第一個字元通常應該是 ``<`` 或 ``>``\ (或 ``!``\ )。填充是程式設計師\\ "
1105
+ "的責任。零重複格式字元不會起作用。相反,使用者必須在需要的地方明確加入 ``'x'`` \\ "
1106
+ "填充位元組。重新檢視上一節的範例,我們有: ::"
1060
1107
1061
1108
#: ../../library/struct.rst:525
1062
1109
msgid ""
@@ -1096,6 +1143,8 @@ msgid ""
1096
1143
"when executed on different machines. For example, the examples below were "
1097
1144
"executed on a 32-bit machine::"
1098
1145
msgstr ""
1146
+ "上述結果(在 64 位元機器上執行)在不同機器上執行時不保證匹配。例如,下面的\\ "
1147
+ "範例是在 32 位元機器上執行的: ::"
1099
1148
1100
1149
#: ../../library/struct.rst:544
1101
1150
msgid ""
@@ -1128,64 +1177,77 @@ msgid ""
1128
1177
"its methods is more efficient than calling module-level functions with the "
1129
1178
"same format since the format string is only compiled once."
1130
1179
msgstr ""
1180
+ "回傳一個新的 Struct 物件,它根據格式字串 *format* 寫入和讀取二進位資料。\\ "
1181
+ "建立一次 ``Struct`` 物件並呼叫其方法比使用相同格式呼叫模組層級函式更有效率,\\ "
1182
+ "因為格式字串只編譯一次。"
1131
1183
1132
1184
#: ../../library/struct.rst:569
1133
1185
msgid ""
1134
1186
"The compiled versions of the most recent format strings passed to the module-"
1135
1187
"level functions are cached, so programs that use only a few format strings "
1136
1188
"needn't worry about reusing a single :class:`Struct` instance."
1137
1189
msgstr ""
1190
+ "傳遞給模組層級函式的最近格式字串的編譯版本會被快取,因此僅使用少數格式字串的\\ "
1191
+ "程式無需擔心重複使用單一\\ :class:`Struct` 實例。"
1138
1192
1139
1193
#: ../../library/struct.rst:574
1140
1194
msgid "Compiled Struct objects support the following methods and attributes:"
1141
- msgstr ""
1195
+ msgstr "編譯的 Struct 物件支援以下方法和屬性: "
1142
1196
1143
1197
#: ../../library/struct.rst:578
1144
1198
msgid ""
1145
1199
"Identical to the :func:`pack` function, using the compiled format. "
1146
1200
"(``len(result)`` will equal :attr:`size`.)"
1147
1201
msgstr ""
1202
+ "與\\ :func:`pack` 函式相同,使用編譯的格式。(``len(result)`` 將等於\\ :attr:`size`。)"
1148
1203
1149
1204
#: ../../library/struct.rst:584
1150
1205
msgid "Identical to the :func:`pack_into` function, using the compiled format."
1151
- msgstr ""
1206
+ msgstr "與 \\ :func:`pack_into` 函式相同,使用編譯的格式。 "
1152
1207
1153
1208
#: ../../library/struct.rst:589
1154
1209
msgid ""
1155
1210
"Identical to the :func:`unpack` function, using the compiled format. The "
1156
1211
"buffer's size in bytes must equal :attr:`size`."
1157
1212
msgstr ""
1213
+ "與\\ :func:`unpack` 函式相同,使用編譯的格式。緩衝區的位元組大小必須等於\\ :attr:`size`。"
1158
1214
1159
1215
#: ../../library/struct.rst:595
1160
1216
msgid ""
1161
1217
"Identical to the :func:`unpack_from` function, using the compiled format. "
1162
1218
"The buffer's size in bytes, starting at position *offset*, must be at "
1163
1219
"least :attr:`size`."
1164
1220
msgstr ""
1221
+ "與\\ :func:`unpack_from` 函式相同,使用編譯的格式。緩衝區從位置 *offset* \\ "
1222
+ "開始的位元組大小必須至少為\\ :attr:`size`。"
1165
1223
1166
1224
#: ../../library/struct.rst:602
1167
1225
msgid ""
1168
1226
"Identical to the :func:`iter_unpack` function, using the compiled format. "
1169
1227
"The buffer's size in bytes must be a multiple of :attr:`size`."
1170
1228
msgstr ""
1229
+ "與\\ :func:`iter_unpack` 函式相同,使用編譯的格式。緩衝區的位元組大小必須是\\ :attr:`size` \\ "
1230
+ "的倍數。"
1171
1231
1172
1232
#: ../../library/struct.rst:609
1173
1233
msgid "The format string used to construct this Struct object."
1174
- msgstr ""
1234
+ msgstr "用於構造此 Struct 物件的格式字串。 "
1175
1235
1176
1236
#: ../../library/struct.rst:611
1177
1237
msgid "The format string type is now :class:`str` instead of :class:`bytes`."
1178
- msgstr ""
1238
+ msgstr "格式字串型別現在是 \\ :class:`str` 而不是 \\ :class:`bytes`。 "
1179
1239
1180
1240
#: ../../library/struct.rst:616
1181
1241
msgid ""
1182
1242
"The calculated size of the struct (and hence of the bytes object produced by "
1183
1243
"the :meth:`pack` method) corresponding to :attr:`format`."
1184
1244
msgstr ""
1245
+ "對應於\\ :attr:`format` 的結構的計算大小(因此也是\\ :meth:`pack` 方法所產生的\\ "
1246
+ "bytes 物件的大小)。"
1185
1247
1186
1248
#: ../../library/struct.rst:619
1187
1249
msgid "The *repr()* of structs has changed. It is now:"
1188
- msgstr ""
1250
+ msgstr "結構的 *repr()* 已經改變。現在是: "
1189
1251
1190
1252
#: ../../library/struct.rst:13
1191
1253
msgid "C"
0 commit comments