簡體   English   中英

如何從已編譯的.exe文件向終端窗口輸出幫助?

[英]How to printout a help to terminal window from compiled .exe file?

我想為用戶顯示有關程序的簡短描述。

我已將pyinstaller將.py文件編譯為.exe,並嘗試使用以下代碼來顯示幫助(如果有任何參數從終端窗口傳遞到.exe文件)。

if len(sys.argv) > 1:
    # argv[1] has your filename
    sys.stdout.write("Description about program...")
    sys.exit("Terminating")

如果有任何參數傳遞給.exe,則該程序將通過sys.exit命令完成,但終端窗口中不會顯示任何打印輸出。

生成.exe時,我在pyinstaller中使用了-w標志。 這就是提示,即使您通過終端窗口啟動程序,它也會抑制控制台輸出。 謝謝大家。

-w, --windowed, --noconsole
    Windows and Mac OS X: do not provide a console window for standard i/o. On Mac OS X this also triggers building an OS X .app bundle. This option is ignored in *NIX systems.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM