**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")
字符串
1条答案
按热度按时间qqrboqgw1#
路径是普通字符串。请尝试使用
driver=webdriver.Chrome(r"C:\Users\acer\Downloads\chromedriver-win64")
在普通字符串中,python将使用
\
进行转义,但如果在字符串前面使用r
,则会使其成为原始字符串。