Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
让我想检查一个A值列表和a一个字符串/值,以下两个版本之间的速度或结果是否存在差异?A
A
a
A = [1, 2, 3] a = 4 if a not in A: print("a is not in A!") if not a in A: print("not a is in A!")
表达式上的 Python 文档讨论了not in运算符的存在。这是否意味着第一个版本更规范?
not in