Add typing annotations to Python codes. (#411)

This commit is contained in:
Yudong Jin
2023-03-12 18:49:52 +08:00
committed by GitHub
parent 2029d2b939
commit 9151eaf533
50 changed files with 577 additions and 817 deletions

View File

@@ -80,7 +80,7 @@
""" 初始化队列 """
# 在 Python 中,我们一般将双向队列类 deque 看作队列使用
# 虽然 queue.Queue() 是纯正的队列类,但不太好用,因此不建议
que = collections.deque()
que: Deque[int] = collections.deque()
""" 元素入队 """
que.append(1)
@@ -90,16 +90,16 @@
que.append(4)
""" 访问队首元素 """
front = que[0];
front: int = que[0];
""" 元素出队 """
pop = que.popleft()
pop: int = que.popleft()
""" 获取队列的长度 """
size = len(que)
size: int = len(que)
""" 判断队列是否为空 """
is_empty = len(que) == 0
is_empty: bool = len(que) == 0
```
=== "Go"