【问题标题】:Is there a Python function for checking the length of an array?是否有用于检查数组长度的 Python 函数?
【发布时间】:2019-09-05 12:01:52
【问题描述】:

我需要计算数组中的项目数。有没有功能可以做到这一点?我可以用 for 循环来做,但如果有一个函数,它会容易 100 倍。

arr1 = [10, 12, 87, 36, 11, 9, 73]
for each in arr1:
    x += 1
 print x

【问题讨论】:

    标签: python-jose


    【解决方案1】:

    您可以尝试使用长度函数:

    len(arr1)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-20
      • 1970-01-01
      • 2021-10-11
      • 2019-06-29
      • 2011-09-30
      • 2021-04-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多