我正在尝试查看是否可以从 NCBI 的 BLAST 中shutil.which()查找命令。blastn在我的终端上运行which blastn会产生/usr/local/bin/blastn. 但是,如果我这样做shutil.which("blastn"),它只会返回None。搜索 Python 工作正常,shutil.which("python")返回/usr/bin/python。为什么会发生这种情况?
我正在尝试使 tkcalendar 与我的窗口融为一体。
import tkinter
from tkcalendar import Calendar
window = tkinter.Tk()
window.configure(background = "black")
cal = Calendar(window, background = "black" , disabledbackground = "black" , borderbackground = "black" , headersbackground = "black" , normalbackground = "black" )
cal.config(background = "black")
cal.pack()
window.mainloop()
Run Code Online (Sandbox Code Playgroud)
我已阅读 tkcalendar 文档并尝试通过调用小部件类的配置方法来更改所有样式元素:
cal.configure(background = "black")
Run Code Online (Sandbox Code Playgroud)
; 但是,我的日历仍然保持灰色,而不是融入黑色窗口背景。是否可以更改日历的实际背景颜色?
我编写了一个简单的程序来从https://stats.nba.com抓取数据。我这里的代码工作得非常好,因为它能够完美地从网站获取数据:
chrome_options = webdriver.ChromeOptions()
d = webdriver.Chrome(ChromeDriverManager().install(),options=chrome_options)
d.get('https://stats.nba.com/teams/advanced/?sort=W&dir=-1')
scrape = BeautifulSoup(d.page_source, 'html.parser').find('table')
for row in scrape.find_all('tr'):
for col in row.find_all('td'):
#...more parsing code here
Run Code Online (Sandbox Code Playgroud)
然而,一旦我添加
chrome_options.add_argument('--headless'),整个代码就会失败并且我得到了AttributeError: 'NoneType' object has no attribute 'find_all'。
为什么会出现这种情况?我到处都找过了,但找不到解决方案。谢谢!
编辑:问题似乎是d.page_source为无头和非无头给出了不同的结果。有谁知道为什么会有差异?
python selenium beautifulsoup web-scraping selenium-chromedriver