mirror of
https://github.com/apachecn/ailearning.git
synced 2026-05-03 10:01:56 +08:00
2020-10-19 21:08:55
This commit is contained in:
@@ -4,14 +4,14 @@
|
||||
|
||||
In [1]:
|
||||
|
||||
```
|
||||
```py
|
||||
import numpy as np
|
||||
|
||||
```
|
||||
|
||||
In [2]:
|
||||
|
||||
```
|
||||
```py
|
||||
a = np.array([[1,2],
|
||||
[3,4]],
|
||||
dtype = np.uint8)
|
||||
@@ -22,14 +22,14 @@ a = np.array([[1,2],
|
||||
|
||||
In [3]:
|
||||
|
||||
```
|
||||
```py
|
||||
a.tostring()
|
||||
|
||||
```
|
||||
|
||||
Out[3]:
|
||||
|
||||
```
|
||||
```py
|
||||
'\x01\x02\x03\x04'
|
||||
```
|
||||
|
||||
@@ -37,14 +37,14 @@ Out[3]:
|
||||
|
||||
In [4]:
|
||||
|
||||
```
|
||||
```py
|
||||
a.tostring(order='F')
|
||||
|
||||
```
|
||||
|
||||
Out[4]:
|
||||
|
||||
```
|
||||
```py
|
||||
'\x01\x03\x02\x04'
|
||||
```
|
||||
|
||||
@@ -56,7 +56,7 @@ Out[4]:
|
||||
|
||||
In [5]:
|
||||
|
||||
```
|
||||
```py
|
||||
s = a.tostring()
|
||||
a = np.fromstring(s,
|
||||
dtype=np.uint8)
|
||||
@@ -66,7 +66,7 @@ a
|
||||
|
||||
Out[5]:
|
||||
|
||||
```
|
||||
```py
|
||||
array([1, 2, 3, 4], dtype=uint8)
|
||||
```
|
||||
|
||||
@@ -74,7 +74,7 @@ array([1, 2, 3, 4], dtype=uint8)
|
||||
|
||||
In [6]:
|
||||
|
||||
```
|
||||
```py
|
||||
a.shape = 2,2
|
||||
a
|
||||
|
||||
@@ -82,7 +82,7 @@ a
|
||||
|
||||
Out[6]:
|
||||
|
||||
```
|
||||
```py
|
||||
array([[1, 2],
|
||||
[3, 4]], dtype=uint8)
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user