Python 相關
Python Programming Language
函式 (function) 和 方法 (method)
requirements.txt
from … import *
Pause (Press the <ENTER> key to continue…)
Bitwise Operation
多重賦值 (Multiple Assignment) 時的計算順序
⭐️ Assignment Expressions 「:=」(賦值後執行 Expressions)
⭐️ assert 斷言
運算子優先序 Operator Precedence
Chaining Comparison Operators (a > b and b > c → a > b > c)
Variable Scope: global, nonlocal
UnboundLocalError (Variable Scope inside a Function)
判斷是否為 空(None) (0 為 False)
any(), all()
Membership Test Operations (in / not in)
match-case: Python 中的 Switch-case
do-while Loop in Python
list, set, dict, collections (deque, defaultdict, Counter)
Enumerate a Multi-Dimensional List
COUNTIF in Python
heapq (優先權佇列 Priority Queue)
List Comprehensions [ … for … in … ]
逆序存取 (for e in lst[::-1])
複製物件 (lst_b = lst_a[:])
f-string (String Formatting)
串接字串 “…”.join()
填充字串長度 rjust()
str 先比較 len 再比較 Lexicographic Order
正則表達式 Regular Expression (re)
計算某元素出現的次數 count()
iterator & generator
Unpacking 解包, *identifier / **identifier
lambda parameter: expression
functools: @lru_cache…
使用 signal 和 decorator 讓函式執行超過時限時中斷
測量片段代碼執行所需時間
Error/Exception Processing (try statement; try-except)
快速套用 try-except 到 method 上 (使用 functools)
程式碼/字串 太長時怎麼換行?
Press the <ENTER> key to continue…
Read All Lines in Text File by Loop (with … as …:)
Sorting 排序
⭐️ Sort by Multiple Keys
⭐️ Python 中的 Binary Search (bisect, insort)
取得 Current Directory/Folder
math: inf, prod(), floor(), ceil(), isqrt()…
asyncio (並行計算)
⭐️ datetime
os
遍歷資料夾 (os.walk(), os.scandir(), os.listdir())
Get the Root Directory/Drive
Web Crawler
Scrapy
requests
Last Updated on 2025/04/11 by A1go