推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
Ewig
V2EX  ›  Python

Python numpy 如何看几维?

  •  
  •   Ewig · Jan 19, 2019 · 4038 views
    This topic created in 2845 days ago, the information mentioned may be changed or developed.
    >>> import numpy as np
    >>> a=np.array([[1,2,3],[3,5,6]])
    >>> b=np.array([1,2,3,4,5],ndmin=2)
    >>> print(b)
    [[1 2 3 4 5]]
    >>> b.shape
    (1, 5)
    >>> com=np.array([a,b,c])
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    NameError: name 'c' is not defined
    >>> com=np.array([a,b,c])
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    NameError: name 'c' is not defined
    >>> c=np.array([[3,2,3],[3,5,6]])
    >>> com=np.array([a,b,c])
    >>> com
    array([array([[1, 2, 3],
    [3, 5, 6]]), array([[1, 2, 3, 4, 5]]),
    array([[3, 2, 3],
    [3, 5, 6]])], dtype=object)
    >>> com.shape
    (3,)
    >>> b.shape
    (1, 5)
    >>> c.shape
    (2, 3)
    >>>


    比如这个怎么看维度啊?(1, 5) 这个是二维的图怎么画出来啊
    4 replies  •  2019-01-21 09:27:27 +08:00
    aijam
    aijam
    Jan 19, 2019
    1
    这个很简单啊
    dangyuluo
    dangyuluo
    Jan 19, 2019
    2
    不看文档的么。。。
    ```python
    a.dim
    ```
    xiao38245
    xiao38245
    Jan 19, 2019
    3
    a.shape, 好好看看文档吧
    Zeeech
    Zeeech
    Jan 21, 2019
    4
    @dangyuluo 正解
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3144 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 04:43 · PVG 12:43 · LAX 20:43 · JFK 23:43
    ♥ Do have faith in what you're doing.