当我启动webbrowser时,如何让Python不退出 [英] How do I make Python not exit when I start webbrowser
问题描述
在我的代码中我使用
import webbrowser
webbrowser.open('http://google.com',new = 2)
和我想要当我运行此命令不退出我的脚本但保持运行因为我想继续该程序,例如当我说你想搜索互联网并且用户说是不关闭我的程序我的代码是:
导入时间
time.sleep(2)
打印(你想去互联网吗?)
yeah1 =输入()
如果yeah1 ==是:
打印(打开网页浏览器)
time.sleep(4)
导入webbrowser
webbrowser.open('http ://google.com',new = 2)
else:
print(Ok那么)
我尝试了什么:
没什么为什么我问这里因为我没有找到解决方案
in my code i use
import webbrowser
webbrowser.open('http://google.com', new=2)
and i want when i run this command not to exit my script but keep it running cuz i want to continue the program for example when i say "do you want to search the internet) and the user say yes not to close my program my code is:
import time
time.sleep(2)
print("would you like to go to the internet?")
yeah1=input()
if yeah1=="yes":
print("Ok opening web browser")
time.sleep(4)
import webbrowser
webbrowser.open('http://google.com', new=2)
else:
print("Ok then")
What I have tried:
nothing that is why i am asking here cuz i didnt found a solution
推荐答案
如果你不想让程序然后你需要创建一个永远持续的循环。
If you do not want the program to terminate then you need to create a loop which continues forever.
这篇关于当我启动webbrowser时,如何让Python不退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!