Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
389 views
in Technique[技术] by (71.8m points)

python - Python中有“不相等”的运算符吗?(Is there a “not equal” operator in Python?)

How would you say does not equal?

(你怎么说不相等?)

Like

(喜欢)

if hi == hi:
    print "hi"
elif hi (does not equal) bye:
    print "no hi"

Is there something equivalent to == that means "not equal"?

(有没有相当于==东西意味着“不平等”?)

  ask by Aj Entity translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use != .

(使用!= 。)

See comparison operators .

(查看比较运算符 。)

For comparing object identities, you can use the keyword is and its negation is not .

(对于比较对象标识,您可以使用关键字is而其否定is not 。)

eg

(例如)

1 == 1 #  -> True
1 != 1 #  -> False
[] is [] #-> False (distinct objects)
a = b = []; a is b # -> True (same object)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...