您的位置:首页 > 编程语言 > Python开发

python 2.7 -1

2016-08-01 19:46 197 查看
Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> c=arrange(24).reshape(2,3,4)

Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
c=arrange(24).reshape(2,3,4)
NameError: name 'arrange' is not defined
>>> c=arange(24).reshape(2,3,4)

Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
c=arange(24).reshape(2,3,4)
NameError: name 'arange' is not defined
>>> c = arange(24).reshape(2,3,4)

Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
c = arange(24).reshape(2,3,4)
NameError: name 'arange' is not defined
>>> a =array([20,30,40,50])

Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
a =array([20,30,40,50])
NameError: name 'array' is not defined
>>> from numpy import *
>>> a =array([20,30,40,50])
>>> a
array([20, 30, 40, 50])
>>> c = arange(24).reshape(2,3,4)
>>> c
array([[[ 0,  1,  2,  3],
[ 4,  5,  6,  7],
[ 8,  9, 10, 11]],

[[12, 13, 14, 15],
[16, 17, 18, 19],
[20, 21, 22, 23]]])
>>> c = arange(24)
>>> c
array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23])
>>> import matplotlib.pyplot as plt

Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
import matplotlib.pyplot as plt
File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 29, in <module>
from matplotlib.figure import Figure, figaspect
File "C:\Python27\lib\site-packages\matplotlib\figure.py", line 36, in <module>
from matplotlib.axes import Axes, SubplotBase, subplot_class_factory
File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 20, in <module>
import matplotlib.dates as _  # <-registers a date unit converter
File "C:\Python27\lib\site-packages\matplotlib\dates.py", line 119, in <module>
from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,
File "C:\Python27\lib\site-packages\dateutil\rrule.py", line 18, in <module>
from six import advance_iterator, integer_types
ImportError: No module named six

>>> import matplotlib.pyplot as plt; plt.plot([1,2,3]); plt.ylabel('some numbers'); plt.show();
Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> linspace(0,2,9)

Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
linspace(0,2,9)
NameError: name 'linspace' is not defined
>>> from numpy import *
>>> linspace(0,2,9)
array([ 0.  ,  0.25,  0.5 ,  0.75,  1.  ,  1.25,  1.5 ,  1.75,  2.  ])
>>> a= arange(15).reshape(3,5)
>>> a
array([[ 0,  1,  2,  3,  4],
[ 5,  6,  7,  8,  9],
[10, 11, 12, 13, 14]])
>>> b=arange(6,7,8)
>>> b
array([6])
>>> b=array(6,7,8)

Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
b=array(6,7,8)
ValueError: only 2 non-keyword arguments accepted
>>> b=array([6,7,8])
>>> b
array([6, 7, 8])
>>> a.shape
(3, 5)
>>> a.ndim
2
>>> a.ndim
2
>>> a.dtype
dtype('int32')
>>>
>>> a.dtype.name
'int32'
>>> a
array([[ 0,  1,  2,  3,  4],
[ 5,  6,  7,  8,  9],
[10, 11, 12, 13, 14]])
>>> a.itemsize
4
>>> a.si

Traceback (most recent call last):
File "<pyshell#18>", line 1, in <module>
a.si
AttributeError: 'numpy.ndarray' object has no attribute 'si'
>>> a.size
15
>>> type
<type 'type'>
>>> type(a)
<type 'numpy.ndarray'>
>>> type(b)
<type 'numpy.ndarray'>
>>> a=array([2,3,4])
>>> a
array([2, 3, 4])
>>> a.dtype
dtype('int32')
>>> b.dtype
dtype('int32')
>>> b
array([6, 7, 8])
>>> b=array([1.2,3.5,5.1])
>>> b
array([ 1.2,  3.5,  5.1])
>>> b.dtype
dtype('float64')
>>>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python