使用窗口批处理运行Python Selenium的命令行窗口后关闭它
我使用Python Selenium来进行Web抓取,使用batch.bat文件触发它。chrome浏览器和命令行窗口在成功运行后仍然打开。它应该关闭,因为我在批处理脚本的末尾放了exit。请参阅下面的代码使用窗口批处理运行Python Selenium的命令行窗口后关闭它,python,selenium,batch-file,command-line,Python,Selenium,Batch File,Command Line,我使用Python Selenium来进行Web抓取,使用batch.bat文件触发它。chrome浏览器和命令行窗口在成功运行后仍然打开。它应该关闭,因为我在批处理脚本的末尾放了exit。请参阅下面的代码 timeout /t 2 /nobreak "C:/Users/h/AppData/Local/Programs/Python/Python37/python.exe" "C:/Users/h/Desktop/Bbq/Python/Test.py" timeout /t 12 /nobrea
timeout /t 2 /nobreak
"C:/Users/h/AppData/Local/Programs/Python/Python37/python.exe" "C:/Users/h/Desktop/Bbq/Python/Test.py"
timeout /t 12 /nobreak
exit
我看了cmd中的消息,这是屏幕截图
我想知道是否有任何错误导致了问题?请告知。使用此异常绕过所有错误,并强制浏览器退出
import traceback.
try:
print(abcd)
except :
print(traceback.format_exc())
print("ERROR")
finally:
driver.quit()
您对Exit命令的作用有一个奇怪的期望,即:退出CMD.EXE程序命令解释器或当前批处理脚本。。它与在批处理脚本或命令窗口中运行的任何程序无关。