我需要一些程序来获取控制台的当前窗口大小
我试过下面的程序
def get_windows_term_width():
from ctypes import windll, create_string_buffer
h = windll.kernel32.GetStdHandle(-12)
csbi = create_string_buffer(22)
res = windll.kernel32.GetConsoleScreenBufferInfo(h, csbi)
if res:
import struct
(bufx, bufy, curx, cury, wattr,
left, top, right, bottom, maxx, maxy) = struct.unpack("hhhhHhhhhhh", csbi.raw)
sizex = right - left + 1
else:
sizex = 90
return sizex
但即使我更改了 cmd.exe 中的设置,我也会将默认设置设为 sizex=90