-1
你好,我是python的新手。 Python IDLE和Pycharm處理is
和==
語句是不同的嗎?在Python IDLE中,對於語句apple is orange
,我得到false
,而在PyCharm中它似乎返回true
。== vs在PyCharm
我已經設置了apple = 500
和orange = 500
。在python IDLE中,我得到false
的apple is orange
,正如我所料,因爲它們是不同的對象。我得到true
爲apple == orange
,因爲兩者都等於500.在Pycharm社區版本中,我設置了if語句來測試相同的語句,並且我爲這兩個語句都得到了true
。
可惜我不能上傳截圖,由於我的名聲不是10
這不是一個PyCharm問題,它是一種語義差異。 – 2014-10-19 16:12:32
[爲什麼在Python中使用'=='或'is'來比較字符串有時會產生不同的結果?](http://stackoverflow.com/questions/1504717/why-does-comparing-strings-in -python-使用-非此即彼此結果有時-產品) – 2014-10-19 16:12:37