簡體   English   中英

通過pythonw.exe運行python程序時獲取用戶輸入

[英]get user input when i run python program through pythonw.exe

我如何才能將python programm作為后台進程運行,並僅顯示cmd用於輸入和輸出操作。 考慮以下代碼:

import pyttsx3;
import pickle;
import speech_recognition as sr
engine = pyttsx3.init();
rate = engine.getProperty('rate')
engine.setProperty('rate', rate-25)
volume = engine.getProperty('volume')
engine.setProperty('volume', volume+0.50)
mic_name = "USB Device 0x46d:0x825: Audio (hw:1, 0)"
sample_rate = 8000
chunk_size = 128
r = sr.Recognizer()
mic_list = sr.Microphone.list_microphone_names()
engine.say(" Hello Mr.amit  , welcome to the first project");
engine.runAndWait();
engine.say("please enter username and password ");
engine.runAndWait();
 print("please enter username and password")
 c=input("Username:")
d=input("Password:")
ss=0
pickle_in = open("dictpersonal.pickle","rb")
users= pickle.load(pickle_in)
for us in users:
  if(c==us):
     engine.say("log in successfully");
     engine.runAndWait();
     print("log in successfully as =",c);
     ss=ss+1;
     break;
if(ss==0):
    engine.say("Username not found.Want to sign up using this username,enter y ");

我只想在需要輸入或輸出操作的情況下打開cmd。如果我使用pythonw.exe運行此程序

pythonw.exe C:\Users\amit\Desktop\MachineLearning\Projects\Personal\f3.py

我無法輸入用戶名和密碼

通過使用pythonw.exe ,整個python進程將無法使用終端。

您可以嘗試使用GUI庫,例如EasyGUI

暫無
暫無

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

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