8000 Translate faq/design.html#why-isn-t-there-a-switch-or-case-statement-… · python/python-docs-zh-tw@00e6c03 · GitHub
[go: up one dir, main page]

Skip to content

Commit 00e6c03

Browse files
committed
Translate faq/design.html#why-isn-t-there-a-switch-or-case-statement-in-python
1 parent a3418ca commit 00e6c03

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

faq/design.po

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,27 +456,36 @@ msgstr ""
456456

457457
#: ../../faq/design.rst:259
458458
msgid "Why isn't there a switch or case statement in Python?"
459-
msgstr ""
459+
msgstr "為什麼 Python 內沒有 switch 或 case 陳述式?"
460460

461461
#: ../../faq/design.rst:261
462462
msgid ""
463463
"You can do this easily enough with a sequence of ``if... elif... elif... "
464464
"else``. For literal values, or constants within a namespace, you can also "
465465
"use a ``match ... case`` statement."
466466
msgstr ""
467+
"你可以用一連串的 ``if... elif... elif... else`` 來輕易達成相同的效果。對於單"
468+
"純的值或是在命名空間內的常數,你也可以使用 ``match ... case`` 陳述式。"
467469

468470
#: ../../faq/design.rst:265
469471
msgid ""
470472
"For cases where you need to choose from a very large number of "
471473
"possibilities, you can create a dictionary mapping case values to functions "
472474
"to call. For example::"
473475
msgstr ""
476+
"如果可能性很多,你可以用字典去映射要呼叫的函式。舉例來說:\n"
477+
"\n"
478+
"::"
474479

475480
#: ../../faq/design.rst:276
476481
msgid ""
477482
"For calling methods on objects, you can simplify yet further by using the :"
478483
"func:`getattr` built-in to retrieve methods with a particular name::"
479484
msgstr ""
485+
"對於呼叫物件裡的方法,你可以利用內建用來找尋特定方法的函式 :func:`getattr` 來"
486+
"做進一步的簡化:\n"
487+
"\n"
488+
"::"
480489

481490
#: ../../faq/design.rst:288
482491
msgid ""
@@ -485,6 +494,8 @@ msgid ""
485494
"from an untrusted source, an attacker would be able to call any method on "
486495
"your object."
487496
msgstr ""
497+
"我們建議在方法名稱加上前綴,以這個例子來說是 像是 ``visit_``。沒有前綴的話,"
498+
"一旦收到從不信任來源的值,攻擊者便可以隨意呼叫在你的專案內的方法。"
488499

489500
#: ../../faq/design.rst:294
490501
msgid ""

0 commit comments

Comments
 (0)
0