问题
I am new in Python and I am using curses for my script.
But when I am try to run the script in server(let say 1) I am getting below error.
_curses.error: addstr() returned ERR
And the same script when I am try to run in another server(let say 2) it is running successfully.
The reason is server 1 is producing more data to display on screen and server 1 is producing less data to display on screen.
So while searching found that curses.intscr() getting the screen size fixed and that's why it is producing error.
So is there any way to overcome it or to increase the screen resolution.
And I am executing this script in linux.
回答1:
You could try splitting your "huge" string:
from __future__ import division #You don't need this in Python3
from math import *
string = "0123456789012345678901234567890123456789"
columns = 5
rows = int(ceil(len(string)/columns))
for row in range(1,rows+1):
panel.addstr(row,1,string[(row*columns)-columns:row*columns])
This will print these strings from the starting one:
01234
56789
01234
56789
01234
56789
01234
56789
This was the answer to this question: Formatting text to fit within a box in Python/Curses
来源:https://stackoverflow.com/questions/18945971/python-issue-with-curses-intscr