Set Windows command-line terminal title in Python

前端 未结 9 1966
攒了一身酷
攒了一身酷 2020-12-01 00:52

I\'m running several instances of a certain Python script on a Windows machine, each from a different directory and using a separate shell windows. Unfortunately Windows giv

9条回答
  •  孤城傲影
    2020-12-01 01:23

    It is now possible to change the window title from within any language via outputting a standard escape sequence to the console (stdout). Here's a working example from a batch file Change command prompt to only show current directory name however just printing ESC close-bracket 2 semicolon your-title-here BEL (control-G) will do it. Also an easily adapted PHP example:

    function windowTitle($title)
      {printf("\033]2;%s\007", $title);}
    

提交回复
热议问题