我正在做一个欢迎信息,我想让它在地下运行,当我在地下运行它时,计算机会像这样弹出终端:"C:\WINDOWS\system32\cmd.exe“我按"X”关闭它,程序将停止并崩溃。我不知道怎么掩饰这件事。
下面是我的代码:
import subprocess
import pyautogui
import time
import pandas as pd
import datetime
import os
import pyttsx3
from tkinter import *
user = "Stark Nguyen" #your name
# Robot speech
# Jarvis_brain = speak
# Jarvis_mouth = engine
assistant= "Jarvis" # Iron man Fan
Jarvis_mouth = pyttsx3.init()
Jarvis_mouth.setProperty("rate", 140)
voices = Jarvis_mouth.getProperty("voices")
Jarvis_mouth.setProperty("voice", voices[1].id)
def Jarvis_brain(audio):
print("Jarvis: " + audio)
Jarvis_mouth.say(audio)
Jarvis_mouth.runAndWait()
# Welcome message
def greet():
hour=datetime.datetime.now().hour
if hour>=0 and hour<12:
Jarvis_brain("Start the system, your AI personal assistant Jarvis")
Jarvis_brain(f"Hello, Good Morning {user}")
print("Hello,Good Morning")
elif hour>=12 and hour<18:
Jarvis_brain("Start the system, your AI personal assistant Jarvis")
Jarvis_brain(f"Hello, Good Afternoon {user}")
print("Hello, Good Afternoon")
else:
Jarvis_brain("Start the system, your AI personal assistant Jarvis")
Jarvis_brain(f"Hello, Good Evening {user}")
print("Hello,Good Evening")
greet()
os.system("python op1.py")
发布于 2021-10-19 17:09:52
如果您将其保存为.pyw文件,就像您在标题中所说的那样,您将隐藏控制台。这样做的缺点是,print()调用不会在任何地方打印,因为它们打印到控制台。
https://stackoverflow.com/questions/68994564
复制相似问题