小编jah*_*max的帖子

检查另一个字符串中是否存在多个字符串

如何检查数组中的任何字符串是否存在于另一个字符串中?

喜欢:

a = ['a', 'b', 'c']
str = "a123"
if a in str:
  print "some of the strings found in str"
else:
  print "no strings found in str"
Run Code Online (Sandbox Code Playgroud)

该代码不起作用,只是为了展示我想要实现的目标.

python arrays string exists

338
推荐指数
6
解决办法
28万
查看次数

如何使用OpenSSL编译.c文件包括?

我正在尝试编译一个包含以下内容的小型.c文件:

#include <openssl/ssl.h>
#include <openssl/rsa.h>
#include <openssl/x509.h>
#include <openssl/evp.h>
Run Code Online (Sandbox Code Playgroud)

在我拥有.c文件的同一个文件夹中,我有一个/ openssl包含所有这些文件(以及更多),同样在synaptic包管理器中我看到安装了OpenSSL,我试图用这个编译:

gcc -o Opentest Opentest.c -lcrypto
Run Code Online (Sandbox Code Playgroud)

但我总是得到错误:

error: openssl/ssl.h: No such file or directory
error: openssl/rsa.h: No such file or directory
error: openssl/x509.h: No such file or directory
error: openssl/evp.h: No such file or directory
Run Code Online (Sandbox Code Playgroud)

我想编译的文件只是一个.c文件,没有Makefile或./configure.

我已经尝试过:

env CFLAGS=-I/path/to/openssl/
Run Code Online (Sandbox Code Playgroud)

并尝试再次编译,但我得到相同的错误.

我应该怎么做才能用openssl编译包括?

c linux compiler-construction openssl compiler-errors

67
推荐指数
4
解决办法
16万
查看次数

Python urllib vs httplib?

什么时候会有人使用httplib和什么时候urllib?

有什么区别?

我想我准备好urllib使用httplib,我打算制作一个需要发出http请求的应用程序,到目前为止我只在python中使用httplib.HTTPConnection请求,并阅读urllib我看到我也可以使用它来获取请求,那么一个或另一个的好处是什么?

python http urllib httplib

53
推荐指数
5
解决办法
4万
查看次数

如何管理python线程结果?

我正在使用此代码:

def startThreads(arrayofkeywords):
    global i
    i = 0
    while len(arrayofkeywords):
        try:
            if i<maxThreads:
                keyword = arrayofkeywords.pop(0)
                i = i+1
                thread = doStuffWith(keyword)
                thread.start()
        except KeyboardInterrupt:
            sys.exit()
    thread.join()
Run Code Online (Sandbox Code Playgroud)

对于python中的线程,我几乎已经完成了所有工作,但我不知道如何管理每个线程的结果,在每个线程上我都有一个字符串数组作为结果,如何安全地将所有这些数组加入一个?因为,如果我尝试写入全局数组,两个线程可能同时写入.

python arrays multithreading

11
推荐指数
2
解决办法
2万
查看次数

Linux中的C线程?

有人在c中有一个简单的线程示例吗?

我想构建一个小型控制台应用程序,它将逐行读取txt文件文件,然后使用线程处理整个txt.我该怎么做?将txt拆分为X,其中X = N的线程,是我想到的第一件事,有更好的方法吗?

c linux multithreading

7
推荐指数
3
解决办法
2万
查看次数

如何在python中正则表达式?

我试图解析谷歌建议的关键字,这是网址:

http://google.com/complete/search?output=toolbar&q=test

我用php完成了它:

'|<CompleteSuggestion><suggestion data="(.*?)"/><num_queries int="(.*?)"/></CompleteSuggestion>|is'
Run Code Online (Sandbox Code Playgroud)

但是这不适用于python re.match(模式,字符串),我尝试了一些,但有些显示错误,有些返回None.

我该如何解析这些信息?我不想使用minidom因为我认为正则表达式会减少代码.

python regex xml parsing

-1
推荐指数
1
解决办法
1203
查看次数