通过pythonw.exe运行python程序时获取用户输入

时间:2018-08-28 05:05:59

标签: python cmd

我如何将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

我无法插入用户名和密码

1 个答案:

答案 0 :(得分:0)

通过使用pythonw.exe,整个python进程将无法使用终端。

您可以尝试使用GUI库,例如EasyGUI