![](/img/trans.png)
[英]What's the correct way to sort Python `import x` and `from x import y` statements?
[英]What is the correct way to compare 2 false statements in python?
給定示例代碼:
if not token == '-' or token == '+':
print token
檢測到-,但未檢測到+
如果我將代碼編輯為:
if not token == '-' or not token == '+':
print token
均未檢測到。
最簡單的方法:
if token not in '-+':
但是傳統上,將not
放在某些問題之外...
if not (token == '-' or token == '+'):
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.