arganzheng · 2026-08-23
x = 1
x = "now string" # 合法,x 绑定了新对象
null vs NoneNullPointerExceptionNone 表示“无值”,但同样会触发属性访问错误is None / is not Noneif user is None:
return "guest"
List<Integer> evens = nums.stream()
.filter(n -> n % 2 == 0)
.collect(Collectors.toList());
evens = [n for n in nums if n % 2 == 0]
def timed(fn):
def wrapper(*args, **kwargs):
return fn(*args, **kwargs)
return wrapper
asyncio,CPU 场景考虑多进程import asyncio
async def fetch_all(urls):
tasks = [fetch(url) for url in urls]
return await asyncio.gather(*tasks)
uv / pip / poetryruff、black、mypy、pytestdataclass 很像轻量 POJOfrom dataclasses import dataclass
@dataclass
class User:
id: int
name: str
__init__ / __repr__ / 比较方法谢谢,欢迎讨论你正在迁移的真实业务场景。