1
此代碼返回終端窗口的大小。這個Python代碼中發生了什麼以獲得終端窗口大小?
def gettermsize():
s = struct.pack("HHHH", 0, 0, 0, 0)
a = struct.unpack('hhhh', fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ , s))
return (a[0], a[1])
它究竟在做什麼?
另請參閱:http://stackoverflow.com/questions/16237137/what-is-termios-tiocgwinsz – phant0m
另請參閱[在C中獲取終端寬度?](http://stackoverflow.com/a/1022961)for一個相當於你的代碼的C語言。 – pascalhein