mirror of
https://github.com/leisurelicht/wtfpython-cn.git
synced 2025-03-06 16:50:09 +08:00
EX.Return return everywhere
This commit is contained in:
parent
9e874c3837
commit
c95600a4f7
10
README.md
10
README.md
@ -27,7 +27,7 @@ So, here we go...
|
|||||||
- [Section: Strain your brain!](#section-strain-your-brain)
|
- [Section: Strain your brain!](#section-strain-your-brain)
|
||||||
- [> Strings can be tricky sometimes/微妙的字符串 *](#-strings-can-be-tricky-sometimes微妙的字符串-)
|
- [> Strings can be tricky sometimes/微妙的字符串 *](#-strings-can-be-tricky-sometimes微妙的字符串-)
|
||||||
- [> Time for some hash brownies!/是时候来点蛋糕了!](#-time-for-some-hash-brownies是时候来点蛋糕了)
|
- [> Time for some hash brownies!/是时候来点蛋糕了!](#-time-for-some-hash-brownies是时候来点蛋糕了)
|
||||||
- [> Return return everywhere!](#-return-return-everywhere)
|
- [> Return return everywhere!/到处返回!](#-return-return-everywhere到处返回)
|
||||||
- [> Deep down, we're all the same. *](#-deep-down-were-all-the-same-)
|
- [> Deep down, we're all the same. *](#-deep-down-were-all-the-same-)
|
||||||
- [> For what?](#-for-what)
|
- [> For what?](#-for-what)
|
||||||
- [> Evaluation time discrepancy](#-evaluation-time-discrepancy)
|
- [> Evaluation time discrepancy](#-evaluation-time-discrepancy)
|
||||||
@ -250,7 +250,7 @@ some_dict[5] = "Python"
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### > Return return everywhere!
|
### > Return return everywhere!/到处返回!
|
||||||
|
|
||||||
```py
|
```py
|
||||||
def some_func():
|
def some_func():
|
||||||
@ -266,10 +266,10 @@ def some_func():
|
|||||||
'from_finally'
|
'from_finally'
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 💡 Explanation:
|
#### 💡 说明:
|
||||||
|
|
||||||
- When a `return`, `break` or `continue` statement is executed in the `try` suite of a "try…finally" statement, the `finally` clause is also executed ‘on the way out.
|
- 当在 "try...finally" 语句的 `try` 中执行 `return`, `break` 或 `continue` 后, `finally` 子句依然会执行.
|
||||||
- The return value of a function is determined by the last `return` statement executed. Since the `finally` clause always executes, a `return` statement executed in the `finally` clause will always be the last one executed.
|
- 函数的返回值由最后执行的 `return` 语句决定. 由于 `finally` 子句一定会执行, 所以 `finally` 子句中的 `return` 将始终是最后执行的语句.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user