我有此代码,但无法正常工作。我该如何解决?
from selenium import webdriver # to control browser operations
from selenium.webdriver.common.keys import keys
from io import Bytesio
from io import Stringio
runfile('/Users/saksham/saksham py/voice.py', wdir='/Users/saksham/saksham py')
Traceback (most recent call last):
File "<ipython-input-1-f68c9e511ab8>", line 1, in <module>
runfile('/Users/saksham/saksham py/voice.py', wdir='/Users/saksham/saksham py')
File "/Users/saksham/anaconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "/Users/saksham/anaconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/Users/saksham/saksham py/voice.py", line 9, in <module>
from selenium.webdriver.common.keys import keys
ImportError: cannot import name 'keys' from 'selenium.webdriver.common.keys' (/Users/saksham/anaconda3/lib/python3.7/site-packages/selenium/webdriver/common/keys.py)
答案 0 :(得分:2)
替换
from selenium.webdriver.common.keys import keys
使用
from selenium.webdriver.common.keys import Keys