Skip to content

Commit daf078e

Browse files
authored
Update python.md
1 parent 6af4f10 commit daf078e

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

introduction/python.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,29 @@ b = tmp
3232
a, b = b, a
3333
```
3434

35+
#### 定义
36+
37+
```Python
38+
ninf = float("-inf")
39+
pinf = float("inf")
40+
```
41+
42+
#### 翻转
43+
```Python
44+
lst = [1, 2, 3, 4, 5]
45+
reversed_lst = lst[::-1]
46+
print(reversed_lst) # 输出:[5, 4, 3, 2, 1]
47+
48+
lst = [1, 2, 3]
49+
lst.reverse()
50+
print(lst) # 输出: [3, 2, 1]
51+
52+
lst = [1, 2, 3]
53+
rev = reversed(lst)
54+
print(list(rev)) # 输出: [3, 2, 1]
55+
print(lst) # 原列表未变: [1, 2, 3]
56+
```
57+
3558
#### 连续不等式或等式
3659

3760
```Python
@@ -78,4 +101,4 @@ Python 的 [collections 库](https://docs.python.org/3/library/collections.html)
78101

79102
## 总结
80103

81-
以上列举了一些用 Python3 做算法题时可以用到的一些特性,标准算法和数据结构,总结得肯定不全,因为 Python3 真的有很多可以利用的"骚操作",大家在学习本项目的时候也会见到,一下记不住也没关系,多实战就会了。
104+
以上列举了一些用 Python3 做算法题时可以用到的一些特性,标准算法和数据结构,总结得肯定不全,因为 Python3 真的有很多可以利用的"骚操作",大家在学习本项目的时候也会见到,一下记不住也没关系,多实战就会了。

0 commit comments

Comments
 (0)