@@ -10,8 +10,8 @@ msgid ""
10
10
msgstr ""
11
11
"Project-Id-Version : Python 3.10\n "
12
12
"Report-Msgid-Bugs-To : \n "
13
- "POT-Creation-Date : 2022-02-20 00:14 +0000\n "
14
- "PO-Revision-Date : 2022-02-07 11:41 +0800\n "
13
+ "POT-Creation-Date : 2022-02-26 00:11 +0000\n "
14
+ "PO-Revision-Date : 2022-03-01 01:14 +0800\n "
15
15
"Last-Translator : Matt Wang <mattwang44@gmail.com>\n "
16
16
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
17
17
"tw)\n "
@@ -964,7 +964,7 @@ msgstr ""
964
964
"此屬性為 :meth:`__missing__` 方法所使用。如果有引數被傳入建構函式,則此屬性會"
965
965
"被初始化成第一個引數,如未提供引數則被初始化為 ``None``。"
966
966
967
- #: ../../library/collections.rst:764 ../../library/collections.rst:1163
967
+ #: ../../library/collections.rst:764 ../../library/collections.rst:1180
968
968
msgid ""
969
969
"Added merge (``|``) and update (``|=``) operators, specified in :pep:`584`."
970
970
msgstr "新增合併 (``|``) 和更新 (``|=``) 運算子,請見 :pep:`584`。"
@@ -1340,48 +1340,92 @@ msgstr ""
1340
1340
1341
1341
#: ../../library/collections.rst:1095
1342
1342
msgid ""
1343
- "Algorithmically, :class:`OrderedDict` can handle frequent reordering "
1344
- "operations better than :class:`dict`. This makes it suitable for tracking "
1345
- "recent accesses (for example in an `LRU cache <https://medium.com/"
1346
- "@krishankantsinghal/my-first-blog-on-medium-583159139237>`_)."
1343
+ "The :class:`OrderedDict` algorithm can handle frequent reordering operations "
1344
+ "better than :class:`dict`. As shown in the recipes below, this makes it "
1345
+ "suitable for implementing various kinds of LRU caches."
1347
1346
msgstr ""
1348
- "在演算法中,\\ :class:`OrderedDict` 比起 :class:`dict` 更適合處理頻繁的重新排"
1349
- "序操作,這讓它適合用於追蹤近期存取紀錄(例如用於 `LRU cache <https://medium."
1350
- "com/@krishankantsinghal/my-first-blog-on-medium-583159139237>`_)。"
1347
+ ":class:`OrderedDict` 比起 :class:`dict` 更適合處理頻繁的重新排序操作,如在下"
1348
+ "方用法中所示,這讓它適合用於多種 LRU cache 的實作中。"
1351
1349
1352
- #: ../../library/collections.rst:1100
1350
+ #: ../../library/collections.rst:1099
1353
1351
msgid ""
1354
1352
"The equality operation for :class:`OrderedDict` checks for matching order."
1355
1353
msgstr ":class:`OrderedDict` 之相等性運算會檢查順序是否相同。"
1356
1354
1357
- #: ../../library/collections.rst:1102
1355
+ #: ../../library/collections.rst:1101
1356
+ msgid ""
1357
+ "A regular :class:`dict` can emulate the order sensitive equality test with "
1358
+ "``p == q and all(k1 == k2 for k1, k2 in zip(p, q))``."
1359
+ msgstr ""
1360
+ "一個一般的 :class:`dict` 可以用 ``p == q and all(k1 == k2 for k1, k2 in "
1361
+ "zip(p, q))`` 來效仿有檢查順序的相等性運算。"
1362
+
1363
+ #: ../../library/collections.rst:1104
1358
1364
msgid ""
1359
1365
"The :meth:`popitem` method of :class:`OrderedDict` has a different "
1360
1366
"signature. It accepts an optional argument to specify which item is popped."
1361
1367
msgstr ""
1362
1368
":class:`OrderedDict` 類別的 :meth:`popitem` 方法有不同的函數簽名 "
1363
1369
"(signature),它接受傳入一個選擇性引數來指定要移除哪個元素。"
1364
1370
1365
- #: ../../library/collections.rst:1105
1371
+ #: ../../library/collections.rst:1107
1372
+ msgid ""
1373
+ "A regular :class:`dict` can emulate OrderedDict's ``od.popitem(last=True)`` "
1374
+ "with ``d.popitem()`` which is guaranteed to pop the rightmost (last) item."
1375
+ msgstr ""
1376
+ "一個一般的 :class:`dict` 可以用 ``d.popitem()`` 來效仿 OrderedDict 的 ``od."
1377
+ "popitem(last=True)``\\ ,這保證會移除最右邊(最後一個)的元素。"
1378
+
1379
+ #: ../../library/collections.rst:1110
1380
+ msgid ""
1381
+ "A regular :class:`dict` can emulate OrderedDict's ``od.popitem(last=False)`` "
1382
+ "with ``(k := next(iter(d)), d.pop(k))`` which will return and remove the "
1383
+ "leftmost (first) item if it exists."
1384
+ msgstr ""
1385
+ "一個一般的 :class:`dict` 可以用 ``(k := next(iter(d)), d.pop(k))`` 來效仿 "
1386
+ "OrderedDict 的 ``od.popitem(last=False)``\\ ,若最左邊(第一個)的元素存在,"
1387
+ "則將其回傳並移除。"
1388
+
1389
+ #: ../../library/collections.rst:1114
1366
1390
msgid ""
1367
1391
":class:`OrderedDict` has a :meth:`move_to_end` method to efficiently "
1368
1392
"reposition an element to an endpoint."
1369
1393
msgstr ""
1370
1394
":class:`OrderedDict` 有個 :meth:`move_to_end` 方法可有效率地將一個元素重新排"
1371
1395
"列到任一端。"
1372
1396
1373
- #: ../../library/collections.rst:1108
1397
+ #: ../../library/collections.rst:1117
1398
+ msgid ""
1399
+ "A regular :class:`dict` can emulate OrderedDict's ``od.move_to_end(k, "
1400
+ "last=True)`` with ``d[k] = d.pop(k)`` which will move the key and its "
1401
+ "associated value to the rightmost (last) position."
1402
+ msgstr ""
1403
+ "一個一般的 :class:`dict` 可以用 ``d[k] = d.pop(k)`` 來效仿 OrderedDict 的 "
1404
+ "``od.move_to_end(k, last=True)``\\ ,這會將該鍵與其對應到的值移動至最右(最後"
1405
+ "面)的位置。"
1406
+
1407
+ #: ../../library/collections.rst:1121
1408
+ msgid ""
1409
+ "A regular :class:`dict` does not have an efficient equivalent for "
1410
+ "OrderedDict's ``od.move_to_end(k, last=False)`` which moves the key and its "
1411
+ "associated value to the leftmost (first) position."
1412
+ msgstr ""
1413
+ "一個一般的 :class:`dict` 沒有和 OrderedDict 的 ``od.move_to_end(k, "
1414
+ "last=False)`` 等價的有效方式,這是將鍵與其對應到的值移動至最左(最前面)位置"
1415
+ "的方法。"
1416
+
1417
+ #: ../../library/collections.rst:1125
1374
1418
msgid "Until Python 3.8, :class:`dict` lacked a :meth:`__reversed__` method."
1375
1419
msgstr "在 Python 3.8 之前,:class:`dict` 並沒有 :meth:`__reversed__` 方法。"
1376
1420
1377
- #: ../../library/collections.rst:1113
1421
+ #: ../../library/collections.rst:1130
1378
1422
msgid ""
1379
1423
"Return an instance of a :class:`dict` subclass that has methods specialized "
1380
1424
"for rearranging dictionary order."
1381
1425
msgstr ""
1382
1426
"回傳一個 :class:`dict` 子類別的實例,它具有專門用於重新排列字典順序的方法。"
1383
1427
1384
- #: ../../library/collections.rst:1120
1428
+ #: ../../library/collections.rst:1137
1385
1429
msgid ""
1386
1430
"The :meth:`popitem` method for ordered dictionaries returns and removes a "
1387
1431
"(key, value) pair. The pairs are returned in :abbr:`LIFO (last-in, first-"
@@ -1393,7 +1437,7 @@ msgstr ""
1393
1437
"回傳鍵值對,否則就按 :abbr:`FIFO (first-in, first-out)` 先進先出的順序回傳鍵"
1394
1438
"值對。"
1395
1439
1396
- #: ../../library/collections.rst:1127
1440
+ #: ../../library/collections.rst:1144
1397
1441
msgid ""
1398
1442
"Move an existing *key* to either end of an ordered dictionary. The item is "
1399
1443
"moved to the right end if *last* is true (the default) or to the beginning "
@@ -1403,15 +1447,15 @@ msgstr ""
1403
1447
"設值)則將元素移至右端;如果 *last* 為假值則將元素移至左端。如果 *key* 不存在"
1404
1448
"則會引發 :exc:`KeyError`:"
1405
1449
1406
- #: ../../library/collections.rst:1144
1450
+ #: ../../library/collections.rst:1161
1407
1451
msgid ""
1408
1452
"In addition to the usual mapping methods, ordered dictionaries also support "
1409
1453
"reverse iteration using :func:`reversed`."
1410
1454
msgstr ""
1411
1455
"除了普通的對映方法,ordered dictionary 還支援了透過 :func:`reversed` 來做倒序"
1412
1456
"疊代。"
1413
1457
1414
- #: ../../library/collections.rst:1147
1458
+ #: ../../library/collections.rst:1164
1415
1459
msgid ""
1416
1460
"Equality tests between :class:`OrderedDict` objects are order-sensitive and "
1417
1461
"are implemented as ``list(od1.items())==list(od2.items())``. Equality tests "
@@ -1425,27 +1469,27 @@ msgstr ""
1425
1469
"和其他 :class:`~collections.abc.Mapping` 物件間的相等性運算則像普通字典一樣不"
1426
1470
"考慮順序性,這使得 :class:`OrderedDict` 可於任何字典可使用的時機中被替換掉。"
1427
1471
1428
- #: ../../library/collections.rst:1154
1472
+ #: ../../library/collections.rst:1171
1429
1473
msgid ""
1430
1474
"The items, keys, and values :term:`views <dictionary view>` of :class:"
1431
1475
"`OrderedDict` now support reverse iteration using :func:`reversed`."
1432
1476
msgstr ""
1433
1477
":class:`OrderedDict` 的項 (item)、鍵與值之\\ :term:`視圖 <dictionary view>`"
1434
1478
"\\ 現在可
10000
過 :func:`reversed` 來倒序疊代。"
1435
1479
1436
- #: ../../library/collections.rst:1158
1480
+ #: ../../library/collections.rst:1175
1437
1481
msgid ""
1438
1482
"With the acceptance of :pep:`468`, order is retained for keyword arguments "
1439
1483
"passed to the :class:`OrderedDict` constructor and its :meth:`update` method."
1440
1484
msgstr ""
1441
1485
"隨著 :pep:`468` 被核可,被傳入給 :class:`OrderedDict` 建構函式與其 :meth:"
1442
1486
"`update` 方法的關鍵字引數之順序被保留了下來。"
1443
1487
1444
- #: ../../library/collections.rst:1168
1488
+ #: ../../library/collections.rst:1185
1445
1489
msgid ":class:`OrderedDict` Examples and Recipes"
1446
1490
msgstr ":class:`OrderedDict` 範例與用法"
1447
1491
1448
- #: ../../library/collections.rst:1170
1492
+ #: ../../library/collections.rst:1187
1449
1493
msgid ""
1450
1494
"It is straightforward to create an ordered dictionary variant that remembers "
1451
1495
"the order the keys were *last* inserted. If a new entry overwrites an "
@@ -1457,19 +1501,19 @@ msgstr ""
1457
1501
"\n"
1458
1502
"::"
1459
1503
1460
- #: ../../library/collections.rst:1182
1504
+ #: ../../library/collections.rst:1199
1461
1505
msgid ""
1462
1506
"An :class:`OrderedDict` would also be useful for implementing variants of :"
1463
1507
"func:`functools.lru_cache`:"
1464
1508
msgstr ""
1465
1509
":class:`OrderedDict` 在實現一個 :func:`functools.lru_cache` 的變形版本時也非"
1466
1510
"常有用:"
1467
1511
1468
- #: ../../library/collections.rst:1280
1512
+ #: ../../library/collections.rst:1297
1469
1513
msgid ":class:`UserDict` objects"
1470
1514
msgstr ":class:`UserDict` 物件"
1471
1515
1472
- #: ../../library/collections.rst:1282
1516
+ #: ../../library/collections.rst:1299
1473
1517
msgid ""
1474
1518
"The class, :class:`UserDict` acts as a wrapper around dictionary objects. "
1475
1519
"The need for this class has been partially supplanted by the ability to "
@@ -1480,7 +1524,7 @@ msgstr ""
1480
1524
"`dict` 建立子類別,這個類別的需求已部分被滿足,不過這個類別使用起來更方便,因"
1481
1525
"為被包裝的字典可以作為其屬性來存取。"
1482
1526
1483
- #: ../../library/collections.rst:1290
1527
+ #: ../../library/collections.rst:1307
1484
1528
msgid ""
1485
1529
"Class that simulates a dictionary. The instance's contents are kept in a "
1486
1530
"regular dictionary, which is accessible via the :attr:`data` attribute of :"
@@ -1492,23 +1536,23 @@ msgstr ""
1492
1536
"`data` 屬性來做存取。如果有提供 *initialdata*\\ ,\\ :attr:`data` 屬性會被初"
1493
1537
"始化為其值;要注意指到 *initialdata* 的參照不會被保留,使其可被用於其他目的。"
1494
1538
1495
- #: ../../library/collections.rst:1296
1539
+ #: ../../library/collections.rst:1313
1496
1540
msgid ""
1497
1541
"In addition to supporting the methods and operations of mappings, :class:"
1498
1542
"`UserDict` instances provide the following attribute:"
1499
1543
msgstr ""
1500
1544
"除了支援作為對映所需的方法與操作,\\ :class:`UserDict` 實例提供了以下屬性:"
1501
1545
1502
- #: ../../library/collections.rst:1301
1546
+ #: ../../library/collections.rst:1318
1503
1547
msgid ""
1504
1548
"A real dictionary used to store the contents of the :class:`UserDict` class."
1505
1549
msgstr "一個真實的字典,用於儲存 :class:`UserDict` 類別的資料內容。"
1506
1550
1507
- #: ../../library/collections.rst:1307
1551
+ #: ../../library/collections.rst:1324
1508
1552
msgid ":class:`UserList` objects"
1509
1553
msgstr ":class:`UserList` 物件"
1510
1554
1511
- #: ../../library/collections.rst:1309
1555
+ #: ../../library/collections.rst:1326
1512
1556
msgid ""
1513
1557
"This class acts as a wrapper around list objects. It is a useful base class "
1514
1558
"for your own list-like classes which can inherit from them and override "
@@ -1519,7 +1563,7 @@ msgstr ""
1519
1563
"入新方法來定義你所需的一個類似於 list 的類別。如此一來,我們可以為 list 加入"
1520
1564
"新的特性。"
1521
1565
1522
- #: ../../library/collections.rst:1314
1566
+ #: ../../library/collections.rst:1331
1523
1567
msgid ""
1524
1568
"The need for this class has been partially supplanted by the ability to "
1525
1569
"subclass directly from :class:`list`; however, this class can be easier to "
@@ -1528,7 +1572,7 @@ msgstr ""
1528
1572
"因為已經可以直接自 :class:`list` 建立子類別,這個類別的需求已部分被滿足,不過"
1529
1573
"這個類別使用起來更方便,因為被包裝的 list 可以作為其屬性來存取。"
1530
1574
1531
- #: ../../library/collections.rst:1320
1575
+ #: ../../library/collections.rst:1337
1532
1576
msgid ""
1533
1577
"Class that simulates a list. The instance's contents are kept in a regular "
1534
1578
"list, which is accessible via the :attr:`data` attribute of :class:"
@@ -1541,21 +1585,21 @@ msgstr ""
1541
1585
"list ``[]``。\\ *list* 可以是任何 iterable,例如一個真實的 Python list 或是一"
1542
1586
"個 :class:`UserList` 物件。"
1543
1587
1544
- #: ../../library/collections.rst:1326
1588
+ #: ../../library/collections.rst:1343
1545
1589
msgid ""
1546
1590
"In addition to supporting the methods and operations of mutable sequences, :"
1547
1591
"class:`UserList` instances provide the following attribute:"
1548
1592
msgstr ""
1549
1593
"除了支援可變序列的方法與操作,\\ :class:`UserList` 實例提供了以下屬性:"
1550
1594
1551
- #: ../../library/collections.rst:1331
1595
+ #: ../../library/collections.rst:1348
1552
1596
msgid ""
1553
1597
"A real :class:`list` object used to store the contents of the :class:"
1554
1598
"`UserList` class."
1555
1599
msgstr ""
1556
1600
"一個真實的 :class:`list` 物件,用於儲存 :class:`UserList` 類別的資料內容。"
1557
1601
1558
- #: ../../library/collections.rst:1334
1602
+ #: ../../library/collections.rst:1351
1559
1603
msgid ""
1560
1604
"**Subclassing requirements:** Subclasses of :class:`UserList` are expected "
1561
1605
"to offer a constructor which can be called with either no arguments or one "
@@ -1569,7 +1613,7 @@ msgstr ""
1569
1613
"例,為了達成上述目的,它假設建構函式可傳入單一參數來呼叫,該參數即是做為數據"
1570
1614
"來源的一個序列物件。"
1571
1615
1572
- #: ../../library/collections.rst:1341
1616
+ #: ../../library/collections.rst:1358
1573
1617
msgid ""
1574
1618
"If a derived class does not wish to comply with this requirement, all of the "
1575
1619
"special methods supported by this class will need to be overridden; please "
@@ -1579,11 +1623,11 @@ msgstr ""
1579
1623
"如果希望一個自此獲得的子類別不遵從上述要求,那所有該類別支援的特殊方法則必須"
1580
1624
"被覆寫;請參考原始碼來理解在這情況下哪些方法是必須提供的。"
1581
1625
1582
- #: ../../library/collections.rst:1347
1626
+ #: ../../library/collections.rst:1364
1583
1627
msgid ":class:`UserString` objects"
1584
1628
msgstr ":class:`UserString` 物件"
1585
1629
1586
- #: ../../library/collections.rst:1349
1630
+ #: ../../library/collections.rst:1366
1587
1631
msgid ""
1588
1632
"The class, :class:`UserString` acts as a wrapper around string objects. The "
1589
1633
"need for this class has been partially supplanted by the ability to subclass "
@@ -1594,7 +1638,7 @@ msgstr ""
1594
1638
"建立子類別,這個類別的需求已經部分被滿足,不過這個類別使用起來更方便,因為被"
1595
1639
"包裝的字串可以作為其屬性來存取。"
1596
1640
1597
- #: ../../library/collections.rst:1357
1641
+ #: ../../library/collections.rst:1374
1598
1642
msgid ""
1599
1643
"Class that simulates a string object. The instance's content is kept in a "
1600
1644
"regular string object, which is accessible via the :attr:`data` attribute "
@@ -1606,21 +1650,21 @@ msgstr ""
1606
1650
"的 :attr:`data` 屬性來做存取。實例內容被初始化為 *seq* 的複製,\\ *seq* 引數"
1607
1651
"可以是任何可被內建函式 :func:`str` 轉換成字串的物件。"
1608
1652
1609
- #: ../../library/collections.rst:1364
1653
+ #: ../../library/collections.rst:1381
1610
1654
msgid ""
1611
1655
"In addition to supporting the methods and operations of strings, :class:"
1612
1656
"`UserString` instances provide the following attribute:"
1613
1657
msgstr ""
1614
1658
"除了支援字串的方法和操作以外,\\ :class:`UserString` 實例也提供了以下屬性:"
1615
1659
1616
- #: ../../library/collections.rst:1369
1660
+ #: ../../library/collections.rst:1386
1617
1661
msgid ""
1618
1662
"A real :class:`str` object used to store the contents of the :class:"
1619
1663
"`UserString` class."
1620
1664
msgstr ""
1621
1665
"一個真實的 :class:`str` 物件,用來儲存 :class:`UserString` 類別的資料內容。"
1622
1666
1623
- #: ../../library/collections.rst:1372
1667
+ #: ../../library/collections.rst:1389
1624
1668
msgid ""
1625
1669
"New methods ``__getnewargs__``, ``__rmod__``, ``casefold``, ``format_map``, "
1626
1670
"``isprintable``, and ``maketrans``."
0 commit comments