Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用selenium的python中出现警告-“字符串中出现异常反斜杠:'\P'_Python_Selenium_Selenium Webdriver_Selenium Chromedriver - Fatal编程技术网

使用selenium的python中出现警告-“字符串中出现异常反斜杠:'\P'

使用selenium的python中出现警告-“字符串中出现异常反斜杠:'\P',python,selenium,selenium-webdriver,selenium-chromedriver,Python,Selenium,Selenium Webdriver,Selenium Chromedriver,我刚刚开始在python中使用selenium。因此,我想在Chrome中使用selenium打开一个类似instagram的页面。但页面一打开,它就会立即关闭。在我的程序的第二行see code中,我一直收到一条警告:字符串中出现异常反斜杠:'\p'。字符串常量可能缺少一个r前缀。pylint a字符串中正常的反斜杠有人能告诉我该怎么做吗?提前谢谢 这是我的密码: from selenium import webdriver PATH = "C:\Program Files (x86

我刚刚开始在python中使用selenium。因此,我想在Chrome中使用selenium打开一个类似instagram的页面。但页面一打开,它就会立即关闭。在我的程序的第二行see code中,我一直收到一条警告:字符串中出现异常反斜杠:'\p'。字符串常量可能缺少一个r前缀。pylint a字符串中正常的反斜杠有人能告诉我该怎么做吗?提前谢谢

这是我的密码:

from selenium import webdriver
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)

driver.get("https://www.instagram.com/?hl=de")

可能是你的chrome驱动程序与你的chrome不在同一个版本中,我刚刚遇到了同样的错误,如果你在地址前加上一个r,错误就会消失

试试这个:

PATH = r"C:\Program Files (x86)\chromedriver.exe"

不,它们有相同的版本。我已经检查过你是否应该将其作为注释发布。C:\Program Files x86\chromedriver.exe可能只需要执行//而不是\。由于你使用的是什么类型的操作系统。不,它仍然不起作用:尝试使用\\然后。它仍然崩溃