我正在尝试使用lxmlBeautifulSoup的解析器,因为默认值较慢,但是我收到此错误:
soup = BeautifulSoup(html, "lxml")
File "/home/rob/python/stock/local/lib/python2.7/site-packages/bs4/__init__.py", line 152, in __init__
% ",".join(features))
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
Run Code Online (Sandbox Code Playgroud)
我已经卸载并重新安装了lxml以及beautifulsoup多次,但它仍然无法读取它.我也尝试重新安装lxml依赖项,我仍然得到这个.
我甚至创建了一个新的虚拟环境并安装了新的一切,但仍然出现此错误.
任何人都知道这里发生了什么?
编辑
在ubuntu桌面上使用Python 2.7.x上的最新版本的bs4和lxml
我可以,import lxml但我不能from lxml import etree回来:
File "<stdin>", line 1, in <module>
ImportError: /usr/lib/x86_64-linux-gnu/libxml2.so.2: version `LIBXML2_2.9.0' not found (required by /home/rob/python/stock/local/lib/python2.7/site-packages/lxml/etree.so)
Run Code Online (Sandbox Code Playgroud)
我有libxml但是我不确定版本,但我安装并重新安装了最新版本.还尝试手动安装2.9.0仍然没有
我有一个数组填充了一个名称,然后是总量的数组.然后根据总排名为该阵列分配"总分".每个等级的积分减少2,但我的问题是如何处理关系?理想情况下,我会看到有多少关系,将这些排名的总积分相加,然后将其除以有多少关系,但我不知道如何真正实现这一点
这是我的数组usort:
function grossSort($gross, $compare) {
if($gross['gross'] > $compare['gross'])
return -1; // move up
else if($gross['gross'] < $compare['gross'])
return 1; // move down
else
return 0; // do nothing
}
Run Code Online (Sandbox Code Playgroud)
把我的数组变成这个:
Array
(
[0] => Array
(
[instr] => lee
[gross] => 2094
)
[1] => Array
(
[instr] => steve
[gross] => 1334
)
[2] => Array
(
[instr] => nick
[gross] => 0
)
[3] => Array
(
[instr] => amber
[gross] => 0
)
[4] => Array …Run Code Online (Sandbox Code Playgroud) 我正在写一个预约类型的东西,我有一个表可能的时间,所以我的第一个查询是列出所有的时间,然后我的第二个表是预定的约会,其中列出了表格内的约会时间和日期匹配从第一个查询中提取的时间和日期.
我无法弄清楚的是,第二个查询中的2个条目是否符合条件以同时显示两个结果.
继承人我的设置:
$query = mysql_query("SELECT * FROM times", $db);
while ($row = mysql_fetch_array($query)){
$time = $row[time];
$query2 = mysql_query("SELECT * FROM appts WHERE time = '$time' AND date = '$date' ", $db);
$apt = mysql_fetch_array($query2);
$aptid = $apt[id];
echo "<tr><td>";
echo date('h:i A', strtotime($row[time]));
echo "</td><td>$apt[name]</td></td><td>$apt[phone]</td><td>$apt[phone2]</td><td>$apt[src]</td><td>$apt[coach]</td><td>$apt[comments]</td><td>";
if($aptid != ''){
echo "<a href='index.php?date=$date&apptid=$aptid&action=delete'>Delete</a> <a href='index.php?date=$date&apptid=$aptid&action=x'>X</a> <a href='index.php?date=$date&apptid=$aptid&action=ns'>NS</a>";
}
echo "</td></tr>";
}
Run Code Online (Sandbox Code Playgroud)
EG:2个约会设定为上午9点,它只显示第一个.见截图
