小编And*_*son的帖子

(安装Python 3.6.1)SSLError:SSL:TLSV1_ALERT_UNKNOWN_CA tlsv1 alert unknown ca

我正在尝试在Ubuntu 16.10上从源代码安装Python 3.6.

make test
Run Code Online (Sandbox Code Playgroud)

当我进行测试时,安装会引发错误说..

======================================================================
ERROR: test_logincapa_with_client_certfile (test.test_imaplib.RemoteIMAP_SSLTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/anderson/Downloads/Python-3.6.1/Lib/test/test_imaplib.py", line 973, in test_logincapa_with_client_certfile
    certfile=CERTFILE)
  File "/home/anderson/Downloads/Python-3.6.1/Lib/imaplib.py", line 1280, in __init__
    IMAP4.__init__(self, host, port)
  File "/home/anderson/Downloads/Python-3.6.1/Lib/imaplib.py", line 197, in __init__
    self.open(host, port)
  File "/home/anderson/Downloads/Python-3.6.1/Lib/imaplib.py", line 1293, in open
    IMAP4.open(self, host, port)
  File "/home/anderson/Downloads/Python-3.6.1/Lib/imaplib.py", line 294, in open
    self.sock = self._create_socket()
  File "/home/anderson/Downloads/Python-3.6.1/Lib/imaplib.py", line 1285, in _create_socket
    server_hostname=self.host)
  File "/home/anderson/Downloads/Python-3.6.1/Lib/ssl.py", line 401, in wrap_socket
    _context=self, _session=session)
  File "/home/anderson/Downloads/Python-3.6.1/Lib/ssl.py", line 808, in __init__
    self.do_handshake() …
Run Code Online (Sandbox Code Playgroud)

python ubuntu ssl openssl python-3.x

12
推荐指数
1
解决办法
1622
查看次数

如何制作基于Python的web框架,如django?

我只是想知道制作像django这样的web框架需要哪些知识或技术.

所以webframework能够作为一个云计算(一个网站可以通过发送一些必须解决的东西水平扩展到其他服务器).如果需要,可以用来像django一样快速建立一个网站,如果开发人员想要的话建立一个简单的网站.

抱歉.因为我是韩国人,我的英语非常尴尬.

只是给我一些方法或说明,了解构建Web框架或我必须做或学习的内容所需的技术.

非常感谢.

python django

9
推荐指数
1
解决办法
1万
查看次数

Mongoengine ...查询不在ListField中的东西?

例如..

class Page(Document)
    tags = ListField(StringField())
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我们可以像这样在标签列表中找到一个值.

Page.objects(tags='coding')
Run Code Online (Sandbox Code Playgroud)

如果标签像['coding','x','y']那么文件将匹配......

但我的问题是如何找到不在列表字段中的值.

我的错误代码将是..

Page.objects(tags!='coding') 
Run Code Online (Sandbox Code Playgroud)

要么

Page.objects(tags__not = 'coding')
Run Code Online (Sandbox Code Playgroud)

要么

Page.objects(tags__not__in = 'coding')
Run Code Online (Sandbox Code Playgroud)

但是......他们不仅仅是工作..

如何查询ListField中没有给定值的文档?

python django mongodb mongoengine

9
推荐指数
1
解决办法
4386
查看次数

Python PIL 0.5不透明度,透明度,alpha

有没有办法让图像半透明?

伪代码是这样的:

from PIL import Image
image = Image.open('image.png')
image = alpha(image, 0.5)
Run Code Online (Sandbox Code Playgroud)

我用谷歌搜索了几个小时,但我找不到任何有用的东西.

python transparency alpha opacity python-imaging-library

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

错误 TypeError:“compilation”参数必须是 Compilation 的实例

如果我跑了npm run serve,那么接下来会发生什么。

 INFO  Starting development server...
 ERROR  TypeError: The 'compilation' argument must be an instance of Compilation
TypeError: The 'compilation' argument must be an instance of Compilation
    at Function.getCompilationHooks (/home/anderson/@python/zeta-value/front/node_modules/webpack/lib/NormalModule.js:193:10)
    at /home/anderson/@python/zeta-value/front/node_modules/vue-loader/lib/plugin-webpack5.js:39:47
    at SyncHook.eval [as call] (eval at create (/home/anderson/@python/zeta-value/front/node_modules/@vue/cli-service/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:5:1)
    at SyncHook.lazyCompileHook (/home/anderson/@python/zeta-value/front/node_modules/@vue/cli-service/node_modules/tapable/lib/Hook.js:154:20)
    at Compiler.newCompilation (/home/anderson/@python/zeta-value/front/node_modules/@vue/cli-service/node_modules/webpack/lib/Compiler.js:631:26)
    at /home/anderson/@python/zeta-value/front/node_modules/@vue/cli-service/node_modules/webpack/lib/Compiler.js:667:29
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/anderson/@python/zeta-value/front/node_modules/@vue/cli-service/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
    at AsyncSeriesHook.lazyCompileHook (/home/anderson/@python/zeta-value/front/node_modules/@vue/cli-service/node_modules/tapable/lib/Hook.js:154:20)
    at Compiler.compile (/home/anderson/@python/zeta-value/front/node_modules/@vue/cli-service/node_modules/webpack/lib/Compiler.js:662:28)
    at /home/anderson/@python/zeta-value/front/node_modules/@vue/cli-service/node_modules/webpack/lib/Watching.js:77:18
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/anderson/@python/zeta-value/front/node_modules/@vue/cli-service/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:22:1)
    at AsyncSeriesHook.lazyCompileHook …
Run Code Online (Sandbox Code Playgroud)

compilation webpack vue.js vue-cli

6
推荐指数
1
解决办法
9263
查看次数

如何在 JNI 中将 char* 转换为 jcharArray

如何在 JNI 中将 char* 转换为 jcharArray?

我必须在 // TODO 注释部分放入什么代码?

JNIEXPORT jcharArray JNICALL Java_finger_FingerPrintJNI_GetVer(JNIEnv *env, jobject thisObj){
    char* version = getText(); // Returns char* data type
    int version_len = strlen(version);

    jcharArray j_version_array = env->NewCharArray(version_len + 1);

    // TODO Convert char* to jcharArray

    return jcharArray;
}
Run Code Online (Sandbox Code Playgroud)

添加 ================================================== ======================

正如 Gearon 建议的那样,当我输入以下代码时,会引发错误。

jchar* jVersion = (jchar*)version;
env->SetCharArrayRegion(jcharArray, 0, version_len, jVersion);
Run Code Online (Sandbox Code Playgroud)

以下是错误信息。

JNIEnv_::SetCharArrayRegion(jcharArray,jsize,jsize,const jchar *)': cannot convert argument 1 from 'jchar *' to 'jcharArray'
sample.cpp(26): note: Types pointed to are unrelated; conversion …
Run Code Online (Sandbox Code Playgroud)

c++ java java-native-interface android

5
推荐指数
2
解决办法
3511
查看次数

为什么要使用is_safe?

我正在阅读关于自定义过滤器的Django文档.

和..我没有看到is_safe存在的原因. https://docs.djangoproject.com/en/1.3/howto/custom-template-tags/#filters-and-auto-escaping

当我编写一些示例然后尝试它们时,无论is_safe是True还是False,结果总是相同的.

为什么使用is_safe?

这是我的代码

extra_tags.py

from django.template.defaultfilters import stringfilter
from django import template
import datetime
register = template.Library()

@register.filter(name='custom_lower')        
@stringfilter
def lower(value):
    is_safe = True
    return '%sxx'%value
lower.is_safe = True;

from django.utils.html import conditional_escape
from django.utils.safestring import mark_safe

@register.filter(name='custom_lf')
def initial_letter_filter(text, autoescape=None):
    first, other = text[0], text[1:]
    if autoescape:
        esc = conditional_escape
    else:
        esc = lambda x: x
    result = '<strong>%s</strong>%s' % (esc(first), esc(other))
    return mark_safe(result)
initial_letter_filter.is_safe = False
initial_letter_filter.needs_autoescape = True
Run Code Online (Sandbox Code Playgroud)

我的观点是,无论我编码is_safe = True还是is_safe = False,结果都将是自动转义字符..我不明白为什么我们使用is_safe.

python django

4
推荐指数
1
解决办法
1445
查看次数

Mongoengine,仅重新获得一些MapField

例如..在Mongodb ..

> db.test.findOne({}, {'mapField.FREE':1})
{
    "_id" : ObjectId("4fb7b248c450190a2000006a"),
    "mapField" : {
            "BOXFLUX" : {
                    "a" : "f",
            }
    }
}
Run Code Online (Sandbox Code Playgroud)

'mapField'字段由Mongoengine的MapField组成.'mapField'字段有一个键和数据的日志..但我只检索'BOXFLUX'..

这个查询在MongoEngine中不起作用....例如..

BoxfluxDocument.objects( ~~ querying ~~ ).only('mapField.BOXFLUX')
Run Code Online (Sandbox Code Playgroud)

你可以看到.. 只有('mapField.BOXFLUX')只有('mapField__BOXFLUX')不起作用.它检索所有'mapField'数据,包括'BOXFLUX'一个..

如何只检索MapField的字段???

python django mongodb pymongo mongoengine

2
推荐指数
1
解决办法
3726
查看次数

在CentOS上使用python模块安装OpenCV出错了

当我运行此命令以使用Python模块安装OpenCV时

cmake ../ -DCMAKE_BUILD_TYPE=RELEASE 
-DCMAKE_INSTALL_PREFIX=/usr/local 
-DBUILD_EXAMPLES=ON 
-DBUILD_NEW_PYTHON_SUPPORT=ON 
-DINSTALL_PYTHON_EXAMPLES=ON 
-DPYTHON_EXECUTABLE=/usr/local/bin/python2.7 
-DPYTHON_INCLUDE_DIR=/usr/local/include/python2.7/ 
-DPYTHON_LIBRARY=/usr/local/lib/python2.7/config/libpython2.7.a 
-DPYTHON_NUMPY_INCLUDE_DIR=/usr/local/lib/python2.7/site-packages/numpy/core/include/ 
-DPYTHON_PACKAGES_PATH=/usr/local/lib/python2.7/site-packages/ 
-DBUILD_PYTHON_SUPPORT=ON
Run Code Online (Sandbox Code Playgroud)

我收到此错误消息.

/usr/bin/ld: /usr/local/lib/python2.7/config/libpython2.7.a(abstract.o): relocation R_X86_64_32 
against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/python2.7/config/libpython2.7.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [lib/cv2.so] Error 1
make[1]: *** [modules/python/CMakeFiles/opencv_python.dir/all] Error 2
make: *** [all] Error 2
Run Code Online (Sandbox Code Playgroud)

我无法理解错误和错误信息.

有人能告诉我这有什么问题吗?

顺便说一句,我的操作系统是CentOS.

我使用Python2.7.5

python linux opencv centos cmake

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

安装Nginx

./configure --user=boxflux 
            --group=boxflux 
            --prefix=/usr/local/nginx-1.3.0                    
            --with-pcre=/usr/lib64 
            --with-md5=/usr/lib64 
            --with-sha1=/usr/lib64 
            --with-zlib=/usr/lib64 
            --with-libatomic=/usr/lib64 
            --with-openssl=/usr/lib64 | grep 'not found'
checking for sys/filio.h ... not found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for F_READAHEAD ... not found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for dlopen() ... not found
checking for SO_SETFIB ... not found
checking for SO_ACCEPTFILTER ... not found
checking for setproctitle() ... not found …
Run Code Online (Sandbox Code Playgroud)

linux nginx yum

0
推荐指数
1
解决办法
1万
查看次数