【发布时间】:2014-09-29 08:03:51
【问题描述】:
headers = table.by_tag('th')
labels = [str(t.content).split('(')[0].strip() for t in headers[3:-1]]
我知道split() 和strip() 是什么意思。但是split('(')[0] 是什么意思? headers 是表格中的内容。
【问题讨论】:
-
split()返回一个列表,因此它为您提供第一个值(第一个子字符串,直到第一个(符号) -
@user3322273 str(t.content) 返回这些:Jerry Brown (D), Meg Whitman(D)
标签: python-2.7 ipython-notebook scientific-computing