简体   繁体   中英

Automatically Resize Command Line Window

I'm writing a program in Python, the data I want it to show must be able to fit on the screen at the same time without needing to scroll around. The default command line size does not allow for this.

Is there any way to automatically resize a command line window in Python without creating a GUI? The program will only be used on windows.

import os

os.system('mode con: cols=100 lines=40')
raw_input("Press any key to continue...")
import os
os.system('mode con: cols=100 lines=40')
input("Press any key to continue...")


#for Python 3 

First get the console window size, then do some proper formatting. You can refer to this page:

http://code.activestate.com/recipes/440694-determine-size-of-console-window-on-windows/

通过右键单击控制台标题栏 -> 属性 -> 布局 -> 窗口大小来更改控制台大小

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM