Python代码写好之后,通过任务计划程序定期执行.py文件,但总会有命令窗口,虽然不影响程序执行,但每次需要手动叉掉比较烦。于是我网上搜索了一些方法。
网上的方法并没有直接解决我的问题,但我借助搜索引擎和chatGPT,成功将代码进行了优化。供大家参考。
from selenium import webdriver
from selenium.webdriver.chrome.service import Service chrome_path = 'E:\Python\chromedriver.exe' options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging']) service = Service(executable_path=chrome_path)
driver = webdriver.Chrome(service=service, options=options) driver.get("http://www.baidu.com")
print("程序运行成功")
在学习Python的过程中,我不断看到其他人优秀的代码,不断从中汲取新的知识和技巧。同时,我也明白分享是一种双赢的行为,因此我始终将自己的学习经验和心得分享给其他人,希望能够为更多的人带来帮助和启发。