Skip to content

Commit 44bc3c3

Browse files
sync with cpython 2426c453
1 parent 912dad1 commit 44bc3c3

File tree

1 file changed

+45
-27
lines changed

1 file changed

+45
-27
lines changed

library/random.po

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: Python 3.14\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2025-12-20 00:15+0000\n"
11+
"POT-Creation-Date: 2026-01-13 03:09+0000\n"
1212
"PO-Revision-Date: 2025-03-07 19:17+0800\n"
1313
"Last-Translator: Dr.XYZ <[email protected]>\n"
1414
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
@@ -1102,10 +1102,13 @@ msgstr ""
11021102
"(combinatoric iterators) 中進行隨機選擇:"
11031103

11041104
#: ../../library/random.rst:635
1105+
#, fuzzy
11051106
msgid ""
1106-
"def random_product(*args, repeat=1):\n"
1107-
" \"Random selection from itertools.product(*args, **kwds)\"\n"
1108-
" pools = [tuple(pool) for pool in args] * repeat\n"
1107+
"import random\n"
1108+
"\n"
1109+
"def random_product(*iterables, repeat=1):\n"
1110+
" \"Random selection from itertools.product(*iterables, repeat=repeat)\"\n"
1111+
" pools = tuple(map(tuple, iterables)) * repeat\n"
11091112
" return tuple(map(random.choice, pools))\n"
11101113
"\n"
11111114
"def random_permutation(iterable, r=None):\n"
@@ -1129,7 +1132,22 @@ msgid ""
11291132
" pool = tuple(iterable)\n"
11301133
" n = len(pool)\n"
11311134
" indices = sorted(random.choices(range(n), k=r))\n"
1132-
" return tuple(pool[i] for i in indices)"
1135+
" return tuple(pool[i] for i in indices)\n"
1136+
"\n"
1137+
"def random_derangement(iterable):\n"
1138+
" \"Choose a permutation where no element stays in its original position."
1139+
"\"\n"
1140+
" seq = tuple(iterable)\n"
1141+
" if len(seq) < 2:\n"
1142+
" if not seq:\n"
1143+
" return ()\n"
1144+
" raise IndexError('No derangments to choose from')\n"
1145+
" perm = list(range(len(seq)))\n"
1146+
" start = tuple(perm)\n"
1147+
" while True:\n"
1148+
" random.shuffle(perm)\n"
1149+
" if all(p != q for p, q in zip(start, perm)):\n"
1150+
" return tuple([seq[i] for i in perm])"
11331151
msgstr ""
11341152
"def random_product(*args, repeat=1):\n"
11351153
" \"從 itertools.product(*args, **kwds) 中隨機選擇\"\n"
@@ -1157,7 +1175,7 @@ msgstr ""
11571175
" indices = sorted(random.choices(range(n), k=r))\n"
11581176
" return tuple(pool[i] for i in indices)"
11591177

1160-
#: ../../library/random.rst:664
1178+
#: ../../library/random.rst:750
11611179
msgid ""
11621180
"The default :func:`.random` returns multiples of 2⁻⁵³ in the range *0.0 ≤ x "
11631181
"< 1.0*. All such numbers are evenly spaced and are exactly representable as "
@@ -1169,7 +1187,7 @@ msgstr ""
11691187
"均勻分佈的,並且可以完全表示為 Python float。但是,該間隔中的許多其他可表示"
11701188
"的 float 不是可能的選擇。 例如 ``0.05954861408025609`` 不是 2⁻⁵³ 的整數倍。"
11711189

1172-
#: ../../library/random.rst:670
1190+
#: ../../library/random.rst:756
11731191
msgid ""
11741192
"The following recipe takes a different approach. All floats in the interval "
11751193
"are possible selections. The mantissa comes from a uniform distribution of "
@@ -1181,7 +1199,7 @@ msgstr ""
11811199
"數 < 2⁵³* 範圍內的整數均勻分佈。指數來自幾何分佈,其中小於 *-53* 的指數的出現"
11821200
"頻率是下一個較大指數的一半。"
11831201

1184-
#: ../../library/random.rst:678
1202+
#: ../../library/random.rst:764
11851203
msgid ""
11861204
"from random import Random\n"
11871205
"from math import ldexp\n"
@@ -1211,15 +1229,15 @@ msgstr ""
12111229
" exponent += x.bit_length() - 32\n"
12121230
" return ldexp(mantissa, exponent)"
12131231

1214-
#: ../../library/random.rst:692
1232+
#: ../../library/random.rst:778
12151233
msgid ""
12161234
"All :ref:`real valued distributions <real-valued-distributions>` in the "
12171235
"class will use the new method::"
12181236
msgstr ""
12191237
"Class 中的所有\\ :ref:`實數分佈 <real-valued-distributions>`\\ 都將使用新方"
12201238
"法: ::"
12211239

1222-
#: ../../library/random.rst:695
1240+
#: ../../library/random.rst:781
12231241
msgid ""
12241242
">>> fr = FullRandom()\n"
12251243
">>> fr.random()\n"
@@ -1233,7 +1251,7 @@ msgstr ""
12331251
">>> fr.expovariate(0.25)\n"
12341252
"8.87925541791544"
12351253

1236-
#: ../../library/random.rst:701
1254+
#: ../../library/random.rst:787
12371255
msgid ""
12381256
"The recipe is conceptually equivalent to an algorithm that chooses from all "
12391257
"the multiples of 2⁻¹⁰⁷⁴ in the range *0.0 ≤ x < 1.0*. All such numbers are "
@@ -1246,7 +1264,7 @@ msgstr ""
12461264
"示的 Python float。(2⁻¹⁰⁷⁴ 是最小為正的非正規化 float,等於 ``math."
12471265
"ulp(0.0)``)"
12481266

1249-
#: ../../library/random.rst:710
1267+
#: ../../library/random.rst:796
12501268
msgid ""
12511269
"`Generating Pseudo-random Floating-Point Values <https://allendowney.com/"
12521270
"research/rand/downey07randfloat.pdf>`_ a paper by Allen B. Downey describing "
@@ -1257,68 +1275,68 @@ msgstr ""
12571275
"pdf>`_ Allen B. Downey 的一篇論文描述了產生比通常由 :func:`.random` 產生的 "
12581276
"float 更 fine-grained(細粒的)的方法。"
12591277

1260-
#: ../../library/random.rst:718
1278+
#: ../../library/random.rst:804
12611279
msgid "Command-line usage"
12621280
msgstr "命令列用法"
12631281

1264-
#: ../../library/random.rst:722
1282+
#: ../../library/random.rst:808
12651283
msgid "The :mod:`!random` module can be executed from the command line."
12661284
msgstr ":mod:`!random` 模組可以從命令列執行。"
12671285

1268-
#: ../../library/random.rst:724
1286+
#: ../../library/random.rst:810
12691287
msgid ""
12701288
"python -m random [-h] [-c CHOICE [CHOICE ...] | -i N | -f N] [input ...]"
12711289
msgstr ""
12721290
"python -m random [-h] [-c CHOICE [CHOICE ...] | -i N | -f N] [input ...]"
12731291

1274-
#: ../../library/random.rst:728
1292+
#: ../../library/random.rst:814
12751293
msgid "The following options are accepted:"
12761294
msgstr "接受以下選項:"
12771295

1278-
#: ../../library/random.rst:734
1296+
#: ../../library/random.rst:820
12791297
msgid "Show the help message and exit."
12801298
msgstr "顯示幫助訊息並退出。"
12811299

1282-
#: ../../library/random.rst:739
1300+
#: ../../library/random.rst:825
12831301
msgid "Print a random choice, using :meth:`choice`."
12841302
msgstr "列印一個隨機選擇,使用 :meth:`choice`。"
12851303

1286-
#: ../../library/random.rst:744
1304+
#: ../../library/random.rst:830
12871305
msgid ""
12881306
"Print a random integer between 1 and N inclusive, using :meth:`randint`."
12891307
msgstr "列印 1 到 N(含)之間的隨機整數,使用 :meth:`randint`。"
12901308

1291-
#: ../../library/random.rst:749
1309+
#: ../../library/random.rst:835
12921310
msgid ""
12931311
"Print a random floating-point number between 0 and N inclusive, using :meth:"
12941312
"`uniform`."
12951313
msgstr "列印 0 到 N(含)之間的隨機浮點數,使用 :meth:`uniform`。"
12961314

1297-
#: ../../library/random.rst:752
1315+
#: ../../library/random.rst:838
12981316
msgid "If no options are given, the output depends on the input:"
12991317
msgstr "如果未給定選項,則輸出取決於輸入:"
13001318

1301-
#: ../../library/random.rst:754
1319+
#: ../../library/random.rst:840
13021320
msgid "String or multiple: same as :option:`--choice`."
13031321
msgstr "字串或多個:與 :option:`--choice` 相同。"
13041322

1305-
#: ../../library/random.rst:755
1323+
#: ../../library/random.rst:841
13061324
msgid "Integer: same as :option:`--integer`."
13071325
msgstr "整數:與 :option:`--integer` 相同。"
13081326

1309-
#: ../../library/random.rst:756
1327+
#: ../../library/random.rst:842
13101328
msgid "Float: same as :option:`--float`."
13111329
msgstr "浮點數:與 :option:`--float` 相同。"
13121330

1313-
#: ../../library/random.rst:761
1331+
#: ../../library/random.rst:847
13141332
msgid "Command-line example"
13151333
msgstr "命令列範例"
13161334

1317-
#: ../../library/random.rst:763
1335+
#: ../../library/random.rst:849
13181336
msgid "Here are some examples of the :mod:`!random` command-line interface:"
13191337
msgstr "以下是 :mod:`!random` 命令列介面的一些範例:"
13201338

1321-
#: ../../library/random.rst:765
1339+
#: ../../library/random.rst:851
13221340
msgid ""
13231341
"$ # Choose one at random\n"
13241342
"$ python -m random egg bacon sausage spam \"Lobster Thermidor aux crevettes "

0 commit comments

Comments
 (0)