From 5b11b6e2817b9d278e878d07ccdff0e1d5864655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=B9=E5=B0=8F=E7=BF=BC?= <75880483+aixcyi@users.noreply.github.com> Date: Mon, 31 Jul 2023 08:49:11 +0800 Subject: [PATCH] doc: update docs/python.md (#405) --- docs/python.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/python.md b/docs/python.md index 40b3cb6..bb719e3 100644 --- a/docs/python.md +++ b/docs/python.md @@ -753,7 +753,7 @@ IndexError: list index out of range ['re', 're', 're'] ``` -### 搜索 +### 搜索 ```python >>> nums = [40, 36, 89, 2, 36, 100, 7, -20.5, -999] @@ -764,6 +764,7 @@ IndexError: list index out of range >>> nums.index(7, 4) # 搜索4之后的元素 6 ``` + 当寻找一个不存在的值时,抛出`ValueError`。 Python 判断 @@ -1223,12 +1224,12 @@ print(string * times) # => hahaha ### 变量 ```python -result: int = 1 + 2 +result: str = 1 + 2 print(result) # => 3 ``` -虽然标注了错误的类型,但不影响正常运行 +错误的类型标注不会影响正常运行,也不会报错 ### 参数