2013年8月24日 星期六

Python: operator priority for ==, in

提供一個Python超新手的錯誤,注意以下程式碼:
>>> b = [1, 2]
>>> False == 3 in b
False

如要得到True,請改成:
>>> False == (3 in b)
True

沒有留言:

張貼留言

Lean 4 極簡教學 (Using VS Code on macOS)

 1. Install Lean Environment: https://lean-lang.org/install/ 試著完Step one, two, three 2. 在VS code下,建一新的project: 取名Hello_World 3. 嘗試執行Main.lea...