即,比较:
1,-1,1
到
1.0,-1, 1
应该是相同的
print("the input and the output are " + ( (input == calc_out) ? "the same" : "not the same"))
但它会出现词汇错误= \
答案 0 :(得分:3)
==
答案 1 :(得分:3)
文档指出various ways您可以比较序列和其他类型:
(1, 2, 3) < (1, 2, 4)
[1, 2, 3] < [1, 2, 4]
'ABC' < 'C' < 'Pascal' < 'Python'
(1, 2, 3, 4) < (1, 2, 4)
(1, 2) < (1, 2, -1)
(1, 2, 3) == (1.0, 2.0, 3.0)
(1, 2, ('aa', 'ab')) < (1, 2, ('abc', 'a'), 4)
所以对你的例子来说:
C:\Users\jon>python
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> [1,-1,1] == [1.0,-1,1]
True
答案 2 :(得分:0)
发现它...... Python确实让Ternary很奇怪:
print("the input and the output are " + ( "the same" if (input == calc_out) else "not the same"))