Why the first code doesn't work while the second does?First code:import seleniumdriver = selenium.webdriver.Firefox()Second code:from selenium import webdriverdriver = webdriver.Firefox() 解决方案 Nested packages are not automatically loaded; not until you import selenium.webdriver is it available as an attribute. Importing just selenium is not enough.Do this:import selenium.webdriverdriver = selenium.webdriver.Firefox()Sometimes the package itself will import a nested package in the __init__.py package initializer; os imports os.path, so os.path is immediately available even if you import just os. 这篇关于为什么导入并不总是导入嵌套包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-05 08:15
查看更多