size函数只能用于计算array,不能用于计算list,返回的是数组的元素个数

len函数既可以计算array,也可以计算list

>>> a = np.array([1,2])
>>> len(a)
2
>>> a.size
2 >>> a = np.array([[1,2],[3,4]])
>>> len(a)
2
>>> a.size
4 >>> a = np.array([[[1,2],[3,4]],[[1,2],[3,4]]])
>>> len(a)
2
>>> a.size
8 >>> a=[[[1,2],[3,4]],[[1,2],[3,4]]]
>>> len(a)
2
>>> a=[[[1,2],[3,4]],[[1,2],[3,4]],[[1,2],[3,4]]]
>>> len(a)
3 >>> a = np.array([[[1,2],[3,4]],[[1,2],[3,4]],[[1,2],[3,4]]])
>>> len(a)
3
>>> a.size
12
>>> a.shape
(3, 2, 2)

可以看出,len返回的是第一维元素的个数

size和len的更多相关文章

  1. [LeetCode] Minimum Size Subarray Sum 最短子数组之和

    Given an array of n positive integers and a positive integer s, find the minimal length of a subarra ...

  2. 【LeetCode 209】Minimum Size Subarray Sum

    Given an array of n positive integers and a positive integer s, find the minimal length of a subarra ...

  3. Minimum Size Subarray Sum 最短子数组之和

    题意 Given an array of n positive integers and a positive integer s, find the minimal length of a suba ...

  4. [LeetCode] 209. Minimum Size Subarray Sum 最短子数组之和

    Given an array of n positive integers and a positive integer s, find the minimal length of a contigu ...

  5. leetcode 714. 买卖股票的最佳时机含手续费

    继承leetcode123以及leetcode309的思路,,但应该也可以写成leetcode 152. 乘积最大子序列的形式 class Solution { public: int maxProf ...

  6. 《徐徐道来话Java》(1):泛型的基本概念

    泛型是一种编程范式(Programming Paradigm),是为了效率和重用性产生的.由Alexander Stepanov(C++标准库主要设计师)和David Musser(伦斯勒理工学院CS ...

  7. MyCat源码分析系列之——结果合并

    更多MyCat源码分析,请戳MyCat源码分析系列 结果合并 在SQL下发流程和前后端验证流程中介绍过,通过用户验证的后端连接绑定的NIOHandler是MySQLConnectionHandler实 ...

  8. 萌新笔记——C++里创建 Trie字典树(中文词典)(二)(插入、查找、导入、导出)

    萌新做词典第二篇,做得不好,还请指正,谢谢大佬! 做好了插入与遍历功能之后,我发现最基本的查找功能没有实现,同时还希望能够把内存的数据存入文件保存下来,并可以从文件中导入词典.此外,数据的路径是存在配 ...

  9. [LeetCode] Concatenated Words 连接的单词

    Given a list of words (without duplicates), please write a program that returns all concatenated wor ...

随机推荐

  1. Spring------约束导入和application.xml的引入方式

    1.spring约束的导入 2.SSH常用约束 3.application.xml的引入方式 <1.通过ClassPathXmlApplicationContext引入配置文件applicati ...

  2. C++ STL:stack和queue

    http://blog.csdn.net/wallwind/article/details/6858634 http://blog.csdn.net/chao_xun/article/details/ ...

  3. K:java中的RMI(Remote Method Invocation)

    相关介绍:  RMI全称是Remote Method Invocation,即远程方法调用.它是一种计算机之间利用远程对象互相调用,从而实现双方通讯的一种通讯机制.使用这种机制,某一台计算机(虚拟机) ...

  4. bzoj1201: [HNOI2005]数三角形----递推+bitset

    -by  bzoj http://www.lydsy.com/JudgeOnline/problem.php?id=1201 枚举所有交点,统计每个以每个点为顶点的正三角和和以每个点为左端点的反三角 ...

  5. 简易搭建git仓库、关联远程和本地仓库方法。克隆仓库方法。同一台电脑上创建两个git ssh key方法。

    一,在github上建仓库 react-js-antd-demo: 二:将远程仓库与本地仓库关联 git remote add origin git@github.com:begin256/react ...

  6. 转 VS Code 快捷键大全,没有更全

    VS Code折腾记 - (2) 快捷键大全,没有更全 前言 VSCode的快捷键继承了一些IDE风格,有VS的身影,也有Emacs的身影..简言之,内置快捷键玩熟了,效率提高不是一点两点. VsCo ...

  7. ES6框架的搭建

    1.引入traceur.js  http://google.github.io/traceur-compiler/bin/traceur.js 2.将Traceur编译器用于网页 new traceu ...

  8. GIS平台结构设计

    前言: WebGIS由于技术发展和功能定位的原因,一般在进行架构设计的时候更多地考虑是否容易实现.用户交互.数据传输方便.渲染效果等方面,对强GIS的应用考虑得少,所以架构上与桌面的GIS平台很不一样 ...

  9. ZooKeeper 典型应用场景

    Zookeeper基础知识 1.zookeeper是一个类似hdfs的树形文件结构,zookeeper可以用来保证数据在(zk)集群之间的数据的事务性一致. 2.zookeeper有watch事件,是 ...

  10. 颤振错误:当前Flutter SDK版本为2.1.0-dev.0.0.flutter-be6309690f?

    我刚刚升级了我的扑动,升级后我无法在Android Studio上运行任何扑动项目.我收到此错误消息. The current Dart SDK version -dev.0.0.flutter-be ...