[Python Unicode SyntaxError] I'd like to know how to solve the error caused by "\U".

Asked 2 years ago, Updated 2 years ago, 69 views

#encoding = utf-8

from selenium import webdriver
from bs4 import BeautifulSoup

driver = webdriver.Chrome ("\Users\choi\chromedriver_win32")
driver.get("https://mensaar.de/#/menu/sb")
bs = BeautifulSoup(driver.page_source, 'html5lib')
print(bs.findAll("div"))

As above, I am trying to parse the page using selenium, but I keep getting errors. Currently, the chromedriver is installed, and it seems that the error recognized as Unicode occurs because of this part of "\U", but the solution found in the stack overflow

It doesn't apply to everyone. The contents of the error are as follows.

C:\Users\choi\AppData\Local\Programs\Python\Python36-32\python.exe C:/Users/choi/PycharmProjects/movie/mensa2.py
  File "C:/Users/choi/PycharmProjects/movie/mensa2.py", line 5
    driver = webdriver.Chrome ("C:\Users\choi\chromedriver_win32")
                              ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

Process finished with exit code 1

python crawling beautifulsoup

2022-09-22 20:06

1 Answers

\User starts with \U.

\ Put two in.

C:\\Users\\choi\\chromedriver_win32


2022-09-22 20:06

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.