我有这样的文字:
text = """<div>
<h1>Title</h1>
<p>A long text........ </p>
<a href=""> a link </a>
</div>"""
Run Code Online (Sandbox Code Playgroud)
使用纯Python,没有外部模块我想要这个:
>>> print remove_tags(text)
Title A long text..... a link
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用lxml.html.fromstring(text).text_content()来实现它,但我需要在纯Python中使用内置或std库实现相同的2.6+
我怎样才能做到这一点?
我正在编写一些与SSH交互的Elixir代码的测试.在我的测试中,我想启动一个SSH服务器,我可以运行我的代码.我更喜欢将此代码存储在测试目录中的自己的文件中,并通过各种不同的测试导入它.
尽管如此,我还是无法让它工作得太好.
我已经尝试创建一个test/ssh_server.ex包含SSHServer模块的文件,但是当我添加import SSHServer到我的测试中时,我得到:
(CompileError)test/end_to_end_test.exs:13:模块SSHServer未加载,无法找到
我错过了什么吗?有没有办法强制mix test导入我的test/ssh_server.ex文件?
g ++说
错误:函数'constexpr std :: tuple的参数太多了
如果我在std::make_tuple通话中省略了static_cast
#include <tuple>
typedef int (*func_t)();
int number() {
return 2;
}
double number(bool a) {
return 1.2;
}
int main() {
// With a static_cast it compiles without any error
// std::tuple<func_t> tup = std::make_tuple(static_cast<func_t>(number));
std::tuple<func_t> tup = std::make_tuple(number);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是完整的错误消息:
$ g++ -std=c++11 test.cc
test.cc: In function 'int main()':
test.cc:31:54: error: too many arguments to function 'constexpr std::tuple<typename std::__decay_and_strip<_Elements>::__type ...> std::make_tuple(_Elements&& ...) [with _Elements = {}; typename std::__decay_and_strip<_Elements>::__type …Run Code Online (Sandbox Code Playgroud) struct Messages
{
template <typename V>
static const char* message() {return "test mesage";}
};
template <int Min, class M=Messages>
struct Test: public M
{
Test()
{
M::message<int>(); //error: expected primary-expression before 'int'
}
};
int main()
{
Test<5, Messages> t;
}
Run Code Online (Sandbox Code Playgroud)
我怀疑这与一些相互依赖有关,比如Test的代码依赖于基类M,其方法在Test中是专用的.它是否正确?
我正在尝试按照这个java教程进行neo4j测试,但是在Clojure中.我正在使用Leiningen进行依赖管理,但该教程使用了maven.根据教程,maven将采用以下依赖XML:
<dependencies>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel</artifactId>
<version>2.0.0</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
...
</dependencies>
Run Code Online (Sandbox Code Playgroud)
它还说:
观察测试罐是至关重要的.如果没有它,您将获得常见的neo4j内核jar,而不是包含测试工具的jar.
我想知道在我的Leiningen project.clj中这相当于什么?显然它的主要部分是,[org.neo4j/neo4j-kernel "2.0.0"]但我如何编码type参数?
我试过[org.neo4j/neo4j-kernel "2.0.0" :type "test-jar"]但是没有用(当我尝试使用:type "blah"它时没有抛出错误,所以我猜Leiningen忽略了这个参数).我也尝试过使用:extension,:scope但是再一次,这些都没有用.