Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python:用什么最快/最优雅的方法来判断两个数组中的每个数字是否相同?_Python - Fatal编程技术网

Python:用什么最快/最优雅的方法来判断两个数组中的每个数字是否相同?

Python:用什么最快/最优雅的方法来判断两个数组中的每个数字是否相同?,python,Python,例如,比较: 1,-1,1 到 应该是一样的 print("the input and the output are " + ( (input == calc_out) ? "the same" : "not the same")) 但是它给出了一个词法错误=\==文档表明您可以比较序列和其他类型: (1, 2, 3) < (1, 2, 4) [1, 2, 3] < [1, 2, 4] 'ABC' < 'C' <

例如,比较:

1,-1,1 

应该是一样的

print("the input and the output are " + ( (input == calc_out) ? "the same" : "not the same"))

但是它给出了一个词法错误=\

==
文档表明您可以比较序列和其他类型:

(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)

找到了。。。Python做了以下工作:

print("the input and the output are " + ( "the same" if (input == calc_out)  else "not the same"))

您是否真的尝试过使用
==
?问题不够具体-您希望输出的内容是什么?如果您发布代码以获得最佳解决方案,您可能会在几分钟内收到相关答案。
1,2,3
3,2,1
相同吗?如果是这样,那就完全不同了。不。。。就在我的例子中,可能有小数。。。但是它们的顺序是一样的=\
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
print("the input and the output are " + ( "the same" if (input == calc_out)  else "not the same"))