PyPyBridge

你已经会编程。
缺的不是 Python 课,
是一张翻译卡

PyBridge 面向 Java / JavaScript / Go 开发者:每课双栏对照「你的写法 → Python 的写法」,讲完立刻在浏览器里运行。不教什么是变量,只教 「你的 HashMap 是 Python 的 dict」。

3 条路径 · 52 条概念映射 · 10 个迁移陷阱 · 浏览器内即跑,无需安装

对照卡 Nº 001 · HashMap → dict

Java
1Map<String, Integer> scores = new HashMap<>();
2scores.put("ada", 96);
3scores.put("lin", 88);
4scores.put("kay", 92);
5
6for (var e : scores.entrySet()) {
7 System.out.println(
8 e.getKey() + ": " + e.getValue());
9}
Python
1scores = {"ada": 96, "lin": 88}
2scores["kay"] = 92
3
4for name, score in scores.items():
5 print(f"{name}: {score}")
6
7print("top:", max(scores, key=scores.get))
  • 点右侧「运行」,右边的代码立刻在你的浏览器里跑起来 —— 不用装任何东西。
  • 整个网站都是这个格式:左边你的语言,右边 Python,讲完就跑。

§ 01选择你的来路

§ 02概念映射词典

打开完整词典(52 条)→

开发中卡住时来查:「我熟悉的 X,在 Python 里叫什么、地道写法长什么样」。

概念JavaJavaScriptGoPython
哈希表HashMap<K,V>{} / Mapmap[K]Vdict
动态数组ArrayList<T>Arrayslicelist
集合去重HashSet<T>Setmap[T]struct{}set
不可变序列List.of(...) 的只读直觉多返回值tuple
纯数据载体record / Lombok @Value对象字面量struct@dataclass
枚举enumconst 对象 / TS enumiota 常量块enum.Enum

§ 03迁移陷阱精选

全部 10 条 →

游乐场已经就绪。

无需注册、无需安装 —— Python 跑在你的浏览器里,60 秒出第一行输出。

打开游乐场