Python 报错 SyntaxError: invalid syntax 解决方法

脚本没有报错,但是有底色标记部分语句,运行后报错信息如下:

C:UsersliushuangAppDataLocalProgramsPythonPython36-32python.exe C:/Users/liushuang/PycharmProjects/11/人员管理/人员清单.py
Traceback (most recent call last):
File "C:/Users/liushuang/PycharmProjects/11/人员管理/人员清单.py", line 2, in <module>
from selenium import webdriver
File "C:UsersliushuangAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdriver\__init__.py", line 18, in <module>
from .firefox.webdriver import WebDriver as Firefox # noqa
File "C:UsersliushuangAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdriverfirefoxwebdriver.py", line 29, in <module>
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
File "C:UsersliushuangAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdriver emotewebdriver.py", line 378
def //*[@id="ItemForm"]/div[2]/div[4]/div[1]/div[2]/inputfind_element_by_xpath(self, xpath):
^
SyntaxError: invalid syntax

解决方案:

卸载selenium:pip uninstall selenium

重新安装:pip install selenium

原文地址:https://www.cnblogs.com/shimo/p/9951275.html