小编2 8*_*2 8的帖子

ValueError:要解压缩的值太多

为什么这段代码错了?

for i,j in range(100),range(200,300):
    print i,j
Run Code Online (Sandbox Code Playgroud)

当我测试这个语句时,我看到了这个错误

ValueError:要解压缩的值太多

但是当我测试的时候

for i, j in range(2),range(2):
     print i,j
Run Code Online (Sandbox Code Playgroud)

一切都是正确的!

python loops

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

程序集中的结构或类

我需要在c ++中使用类似struct或class的东西

例如,我需要一个带有数组和两个属性(size和len)的类,以及一些像append和remove这样的函数.

如何在汇编中使用宏和过程实现它?

macros assembly class masm

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

以下有django neomodel的型号

我使用neo4j数据库和django-neomodel,我想为我的用户实现一个关注系统,并为用户编写这个模型:

class UserNode(StructuredNode):
    user_id = IntegerProperty(required=True, index=True)
    follow = RelationshipTo('UserNode','FOLLOW')

    def get_followers(self):
        results, metadata = self.cypher("START a=node({self}) MATCH a<-[:FOLLOW]-(b) RETURN b");
        return [self.__class__.inflate(row[0]) for row in results]

    def get_following(self):
        results, metadata = self.cypher("START a=node({self}) MATCH b-[:FOLLOW]->(a) RETURN b");
        return [self.__class__.inflate(row[0]) for row in results]

    def follow_person(self, user_id):
        import datetime
        from django.utils.timezone import utc

        followed_user = self.index.get(user_id=user_id)
        self.follow.connect(followed_user, {'time': str(datetime.datetime.utcnow().replace(tzinfo=utc))})
        self.save()
        followed_user.save()
Run Code Online (Sandbox Code Playgroud)

您认为我的UserNode模型适用于以下系统是一个很好的模型吗?

这个模型出现了问题!当我运行此代码时:

a = UserNode.index.get(user_id=200)
b = UserNode.index.get(user_id=201)
c = UserNode.index.get(user_id=202)

a.follow_person(201)
b.follow_person(200)

print a.get_followers(), a.get_following()
Run Code Online (Sandbox Code Playgroud)

输出是两个空列表.为什么?

python django neo4j graph-databases cypher

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

ValueError:找不到hazm library-python NLP的stanford-postagger.jar文件

我想运行一个需要stanford postagger.jar的代码.但我有这个错误:

  File "/usr/lib/python2.7/site-packages/nltk/internals.py", line 562, in find_jar
    (name, path_to_jar))
ValueError: Could not find stanford-postagger.jar jar file at resources/stanford-postagger.jar
Run Code Online (Sandbox Code Playgroud)

我怎么能解决这个错误?

编辑: 我使用hazm模块:

from hazm import POSTagger
tagger = POSTagger()
tagger.tag(word_tokenize('?? ????? ???? ?????????'))
Run Code Online (Sandbox Code Playgroud)

并且完整结果:

Traceback (most recent call last):
  File "pyt.py", line 8, in <module>
    tagger = POSTagger()
  File "/home/vahid/dev/hazm/hazm/POSTagger.py", line 14, in __init__
    super(stanford.POSTagger, self).__init__(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/nltk/tag/stanford.py", line 42, in __init__
    verbose=verbose)
  File "/usr/lib/python2.7/site-packages/nltk/internals.py", line 562, in find_jar
    (name, path_to_jar))
ValueError: Could not find stanford-postagger.jar jar …
Run Code Online (Sandbox Code Playgroud)

python java nlp nltk pos-tagger

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

调用以某事开头的所有类方法

假设我们有一个这样的类:

class Test(object):

   def __init__(self):
      pass

   def fetch_a(self):
      print "a"

   def fetch_b(self):
      print "b"
Run Code Online (Sandbox Code Playgroud)

我想调用这个类的所有函数,这些函数以init函数中的"fetch"开头.我怎么做这项工作

python class

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

C编译器标识未知

我想编译一个C程序.我跑的时候cmake

   build]$ cmake ../
    -- The C compiler identification is unknown
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- broken
    CMake Error at /usr/share/cmake-3.0/Modules/CMakeTestCCompiler.cmake:61 (message):
      The C compiler "/usr/bin/cc" is not able to compile a simple test program.
Run Code Online (Sandbox Code Playgroud)

它失败并带有以下输出:

   Change Dir: /home/vahid/dev/Indexer/build/CMakeFiles/CMakeTmp

  Run Build Command:"/usr/bin/make" "cmTryCompileExec3431547622/fast"

  /usr/bin/make -f CMakeFiles/cmTryCompileExec3431547622.dir/build.make
  CMakeFiles/cmTryCompileExec3431547622.dir/build

  make[1]: Entering directory
  '/home/vahid/dev/Indexer/build/CMakeFiles/CMakeTmp'

  /usr/bin/cmake -E cmake_progress_report
  /home/vahid/dev/Indexer/build/CMakeFiles/CMakeTmp/CMakeFiles 1

  Building C object
  CMakeFiles/cmTryCompileExec3431547622.dir/testCCompiler.c.o

  /usr/bin/cc -o CMakeFiles/cmTryCompileExec3431547622.dir/testCCompiler.c.o
  -c /home/vahid/dev/Indexer/build/CMakeFiles/CMakeTmp/testCCompiler.c

  /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/cc1: error while loading …
Run Code Online (Sandbox Code Playgroud)

cmake

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

设置绘制二叉树的位置

我想绘制一个带有图形框架(Qt)的二叉树,如下所示:

        9
       /  \
      1    10
    /  \     \
   0    5     11
  /    /  \
 -1   2    6
Run Code Online (Sandbox Code Playgroud)

但是我为每个节点设置X和Y都有问题,你是否知道设置和固定位置?(我只有每个节点的高度和左 - 儿童和右儿童)

algorithm tree drawing binary-tree drawing2d

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

在ubuntu上安装PyXML

我需要在python 2.7.5上安装PyXML,

:~/Desktop/PyXML-0.8.4$ sudo python setup.py install 
running install
running build
running build_py
running build_ext
building '_xmlplus.parsers.pyexpat' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DXML_NS=1 -DXML_DTD=1 -DBYTEORDER=1234 -DXML_CONTEXT_BYTES=1024 -Iextensions/expat/lib -I/usr/include/python2.7 -c extensions/pyexpat.c -o build/temp.linux-x86_64-2.7/extensions/pyexpat.o
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DXML_NS=1 -DXML_DTD=1 -DBYTEORDER=1234 -DXML_CONTEXT_BYTES=1024 -Iextensions/expat/lib -I/usr/include/python2.7 -c extensions/expat/lib/xmlparse.c -o build/temp.linux-x86_64-2.7/extensions/expat/lib/xmlparse.o
extensions/expat/lib/xmlparse.c:75:2: error: #error memmove does not exist on this platform, nor is a substitute available
 #error memmove does not exist on this …
Run Code Online (Sandbox Code Playgroud)

python package

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

mongoengine独特的约束

我有这个模型:

class SourceModel(Document):
    name = StringField(
        primary_key=True,
        max_length=50,
        required=True,
    )
    # some fields
Run Code Online (Sandbox Code Playgroud)

当我尝试运行此代码时:

for source in SOURCES:
    SourceModel(**source).save()
Run Code Online (Sandbox Code Playgroud)

我有这个错误:

mongoengine.errors.NotUniqueError: Tried to save duplicate unique keys (E11000 duplicate key error index: mirad.source_model.$name_1  dup key: { : null })
Run Code Online (Sandbox Code Playgroud)

我不知道为什么会发生此错误,原因unique是我的模型中没有此字段。我将此代码更改为:

for source in SOURCES:

    try:
        SourceModel(**source).save()
    except NotUniqueError:
         old_source = SourceModel.objects(name=source['name']).first()
         print old_source  # this line print None
Run Code Online (Sandbox Code Playgroud)

为什么

model mongodb mongoengine python-2.7

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

/ usr/bin/ld:找不到-lhdf5_hl

我正在尝试编译caffe,在运行make all命令时,我遇到了这个链接错误:

LD -o .build_release/lib/libcaffe.so.1.0.0-rc3
/usr/bin/ld: cannot find -lhdf5_hl
/usr/bin/ld: cannot find -lhdf5
collect2: error: ld returned 1 exit status
Makefile:566: recipe for target '.build_release/lib/libcaffe.so.1.0.0-rc3' failed
make: *** [.build_release/lib/libcaffe.so.1.0.0-rc3] Error 1
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

installation compilation ld caffe

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