【发布时间】:2015-09-29 06:06:53
【问题描述】:
假设我在一个数组中有 2 个数组,例如:
main_array = [[1, 2, 3, 4], [4, 5, 6, 7]]
我想找到每个数组的min 和max 并将它们存储在一个数组中。对于上述情况,它将是:
result = [1, 4, 4, 7]
在这种情况下,如何使用 Python 的内置 min() 和 max()?
我试过 min(main_array) 和 max(main_array) 但这给了我:
result = [1,7]
【问题讨论】:
-
您好,欢迎来到 StackOverflow。请花一些时间阅读帮助页面,尤其是名为"What topics can I ask about here?" 和"What types of questions should I avoid asking?" 的部分。更重要的是,请阅读the Stack Overflow question checklist。您可能还想了解Minimal, Complete, and Verifiable Examples。
-
显示你做了什么