Expand width of shell in Python's IDLE

2019-04-09 19:42发布

问题:

I'm new to python and I'm using Python's IDLE. Using numpy, I created a 24 x 24 matrix. I simply want to look at the matrix. I've maximized the shell on my monitor, so there's plenty of room to print the entire 24 columns' width, but it's only printing the first 13 columns of then continuing onto the next line to print the next 11 columns (had trouble in Stack Overflow copying and pasting what it's doing). The entire right half of the Shell window is blank (it's compressing everything to fit in the left half).

This is harder to read than if it printed 24 columns wide. Can anyone tell me how to convince IDLE to print using the entire width available of the shell (rather than just the left half)? I recognize this is a bit of a stupid question and apologize, but it's driving me crazy.

It looks sort of like this (again, Stack Overflow problems in trying to paste):

[ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
[ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
[ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.]])

Thanks, Mitch

回答1:

Do

import numpy as np
np.set_printoptions(linewidth=999999)

For more, check

help(np.set_printoptions)