Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个数字方阵,并且只想打印一部分数据,例如:
我有:
[1, 2, 3, 0, 0] [6, 7, 2, 0, 0] [4, 5, 8, 0, 0] [0, 0, 0, 0, 0] [0, 0, 0, 0, 0]
我只想打印:
[1, 2, 3] [6, 7, 2] [4, 5, 8]
那可能吗?
假设您正在使用 NumPy(并且您应该使用),只需将其切片:
print a[:3, :3]