簡體   English   中英

Windows中的“刷新”命令行

[英]“Refreshing” Command Line in Windows

我幾天前開始學習python,我寫了一些簡單的程序。 用戶輸入數據,並提供有關數據的信息。

while True:
 x = input("Enter Data: ")

 if x == z:
            print("")


 if x == y:
            print("") 
 if x == l:
            print("")


 if x == k:
            print("") 

我在Windows命令行中使用程序。 我想做的是:當您“輸入數據”並且程序為您提供信息時,按Enter鍵並刷新命令行,然后再次出現“輸入數據”

在Windows上,您可以使用cls清除屏幕(有關詳細信息,請參閱此問題 ):

import os
import sys

while True:
    value = raw_input('Enter data: ')

    if value == 'quit':
        break

    print value

    # wait for enter key
    sys.stdin.read(1)
    os.system('cls')

詛咒示例:

import curses

w = curses.initscr()

while True:
    w.addstr("Enter data: ")
    value = w.getstr()

    if value == 'quit':
        break

    w.addstr('data: %s\n' % value)

    w.addstr('Press any key to continue')
    w.getch()
    w.clear()
    w.refresh()

curses.endwin()

while True:表示“繼續這樣做”。 因此,它將繼續要求您輸入數據。 也許您正在尋找的是定義一個函數def ask():相反,然后在命令行中鍵入ask() ,它只會提示您一次,這就是我在猜測的內容想。

暫無
暫無

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

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