---
title: "Discussion on \"在 Python 中模拟 switch 语句的 fall-through 行为\" | Hashnode"
description: "Discussion on \"在 Python 中模拟 switch 语句的 fall-through 行为\". 什么是 fall-through\n在 JavaScript 中，switch 语句允许 fall-through 行为。当在 switch 语句中发现匹配条件时，相应的代码块将被执行，直到遇到 break 语句，此时 switch 语句将退出。如果没有提供 break 语句，程序将继续执行下一个 case，而不管它是否与条件匹配。这就是所谓的 fall-through 行为。\nswitch (Animal) {\n    case \"Dog\":\n    case \"Cow\":\n        co..."
url: "https://hashnode.com/posts/mimic-the-fall-through-behavior-of-switch-in-python-cn/65c083ca2b3afc54887c6111"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [在 Python 中模拟 switch 语句的 fall-through 行为](https://blog.iread.fun/mimic-the-fall-through-behavior-of-switch-in-python-cn?utm_source=hashnode&utm_medium=feed)

什么是 fall-through 在 JavaScript 中，switch 语句允许 fall-through 行为。当在 switch 语句中发现匹配条件时，相应的代码块将被执行，直到遇到 break 语句，此时 switch 语句将退出。如果没有提供 break 语句，程序将继续执行下一个 case，而不管它是否与条件匹配。这就是所谓的 fall-through 行为。 switch (Animal) { case "Dog": case "Cow": co...

Feb 5, 2024 · 3 min read · blog.iread.fun  
Read the article

-   [#fall-through](https://hashnode.com/tag/fall-through)
-   [#switch-case](https://hashnode.com/tag/switch-case)
-   [#match-case](https://hashnode.com/tag/match-case)
-   [#python3](https://hashnode.com/tag/python3)
-   [#javascript-control-flow](https://hashnode.com/tag/javascript-control-flow)

## Written by

[v like](https://hashnode.com/@likev)

@likev

  
[View profile](https://hashnode.com/@likev)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
