selenium chromewebdriver不启动

ht4b089n  于 11个月前  发布在  其他
关注(0)|答案(1)|浏览(143)
**from selenium import webdriver
driver=webdriver.Chrome("C:\Users\acer\Downloads\chromedriver-win64")
driver.get("https://google.com")
**

C:\Users\acer\PycharmProjects\python_selenium\.venv\Scripts\python.exe C:\Users\acer\PycharmProjects\python_selenium\Test_case01\Login.py 
  File "C:\Users\acer\PycharmProjects\python_selenium\Test_case01\Login.py", line 2
    driver=webdriver.Chrome("C:\Users\acer\Downloads\chromedriver-win64")
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

Process finished with exit code 1

Change  to following script

from selenium import webdriver
driver=webdriver.Chrome("C:\Users\acer\Downloads\chromedriver-win64\chromedriver.exe")
driver.get("https://google.com")

字符串

qqrboqgw

qqrboqgw1#

路径是普通字符串。请尝试使用driver=webdriver.Chrome(r"C:\Users\acer\Downloads\chromedriver-win64")
在普通字符串中,python将使用\进行转义,但如果在字符串前面使用r,则会使其成为原始字符串。

相关问题