python - “无”出现在矩阵之前
问题描述
我编写了一个程序,它生成矩阵 7x7,然后对其进行旋转和转置。在输出中我看到这个“无”
import time
import numpy as np
matsize = np.array([7,7])
matrix = np.random.randint(1000,size=(matsize))
print('\nSwource matrix:\n', matrix, '\n')
rotmatr = np.rot90(matrix, k=-1)
print('Rotation to 90 degrees...\n')
print(time.sleep(2), rotmatr, '\n')
transpos = np.transpose(rotmatr)
print('Transposing...\n')
print(time.sleep(2), transpos)
代码如何工作的示例
Swource matrix:
[[909 859 984 490 773 696 576]
[780 645 632 233 109 181 18]
[ 81 890 328 746 930 45 999]
[944 992 556 436 545 210 814]
[192 827 820 321 45 959 940]
[921 529 276 996 141 132 183]
[235 842 287 169 71 857 70]]
Rotation to 90 degrees...
None [[235 921 192 944 81 780 909]
[842 529 827 992 890 645 859]
[287 276 820 556 328 632 984]
[169 996 321 436 746 233 490]
[ 71 141 45 545 930 109 773]
[857 132 959 210 45 181 696]
[ 70 183 940 814 999 18 576]]
Transposing...
None [[235 842 287 169 71 857 70]
[921 529 276 996 141 132 183]
[192 827 820 321 45 959 940]
[944 992 556 436 545 210 814]
[ 81 890 328 746 930 45 999]
[780 645 632 233 109 181 18]
[909 859 984 490 773 696 576]]
Process finished with exit code 0
这个NONE是什么以及如何删除它???
解决方案
如果你time.sleep(2)
从你的print
陈述中删除,那将删除None
推荐阅读
- selenium - 在 selenium 中验证 webelemnt 位置
- reactjs - 如何在 JSX 中使用 amp-state?
- python - python的aubio库中缓冲区大小和跃点大小的作用是什么?
- python - Python中基于多列垂直展平多列并合并
- powershell - 如何使用powershell检查重复的多个文件?
- django - 如何在 django 中创建 2 级管理员用户,每个用户将只管理他创建的用户?
- if-statement - Vlookup 然后在 Google 表格中返回不同的行
- c++ - 由于某种原因,我的代码中出现了 [json.exception.type_error.302] 。我知道错误是什么意思,但我不知道哪里有问题
- php - 为什么在 YII2 活动表单中没有定义 $model 变量时出现错误
- matlab - MATLAB:x 轴上绘制的是什么?