[英]Center input in python cmd?
我正在使用python中的經典文本冒險端口。
我想知道是否可以集中用戶輸入? 我發現使用str.center()方法可以將打印的文本居中,但是不能將python input()函數居中。 使用str.center()可以給我以下信息:
如您所見,輸入從中間開始,然后再繼續向右
我想做的是,無論用戶輸入什么,它都會像這樣進入中間: (同樣,如果您想知道,我沒有解決自己的問題,這只是使用打印而不是輸入的模擬)
所以我想知道我該怎么做? 使用str.center()或Curses還是其他東西?
你可以用詛咒來做到這一點。 input()和str.center()不會有太大幫助,因為它們事先不知道屏幕的寬度(以及在輸入字符串時如何居中輸入字符串)。
input()
str.center()
使用curses,您可以使用filter功能來擱置屏幕的當前行(而不是擦除整個屏幕...),使用newwin在該行中創建一個窗口,並使用mvwin調整輸入位置的窗口位置(或或者只是在原始stdscr move )。 有多種使用curses實現此目的的方法,但是比input()更復雜。
filter
newwin
mvwin
stdscr
move
[英](Python) “auto input in cmd”
[英]Center method in input and multiline on python
[英]Using utf-8 input for cmd Python module
[英]How to give cmd automated input via python
[英]raw_input in python variable to cmd
[英]Reading input file to Python script, using CMD
[英]Python how to stop the interference of a print and input in cmd?
[英]How to extract filenames from cmd input in python
[英]Python_input txt file by the cmd
[英]python ttk.Entry how to center the input
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.