Datawhale 11 月组队学习笔记(
不同类型文件的输入和输出
练习
# 只打印或显示numpy数组rand_arr的小数点后3位
import numpy as np
np.set_printoptions(precision=3)
rand_arr = np.random.random([5, 3])
print(rand_arr)
# [[0.849 0.47 0.37 ]
[0.842 0.728 0.06 ]
[0.286 0.905 0.926]
[0.283 0.443 0.845]
[0.699 0.503 0.802]]
# 将numpy数组a中打印的项数限制为最多6个元素
np.set_printoptions(threshold=6)
a = np.arange(1000)
print(a)
#[ 0 1 2 ... 997 998 999]
# 打印完整的numpy数组a而不中断
np.set_printoptions(threshold=np.iinfo(np.int).max)
a = np.arange(1000)
print(a)
#[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
96 97 98 99]