Strict comparison

后端 未结 5 1815
再見小時候
再見小時候 2021-01-17 11:43

In javascript, there are strict comparison operators op1 === op2 and op1 !== op2 that will compare both type and value. Is there a pythonic way of

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-17 12:25

    Python's equal comparator is for the most part always strict.

    For example:

    Python

    0 == '0'  # False
    0 == ''  # False
    

    Javascript

    0 == '0'  //True
    0 === '0'  //False
    0 == ''  //True
    0 === '0' //False
    

提交回复
热议问题