-2
私はPythonコンソールでいくつかのサンプルを試します。Pythonで何が意味するのか
>>> (1 and None)
>>> (1 and None) == None
True
>>> (1 or None) == None
False
>>> (1 and 2) == 2
True
>>> (2 and 1) == 2
False
>>> (2 and 1) == 1
True
私は(1、なし)は、任意のものがライン1で返されない理由であるもののために混乱していた。そして、次のために混乱していましたか?それは何もないはずですか?そして、なぜ(2と1)が1に等しいのか2ではないのですか?
'print(1とNone)'を試してください。明示的に印刷するよう指示されない限り、シェルは 'None'を出力しません。 – JRodDynamite
なぜ「None」が表示されないのか:http://stackoverflow.com/questions/39639342/none-is-not-displayed-as-i-expected-in-python-interactive-mode –
docs:https: //docs.python.org/3/library/stdtypes.html#truth-value-testing(4.1および4.2) –