我需要一些程序来获取控制台的当前窗口大小
我试过以下程序
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