小编eri*_*rip的帖子

由于令牌无效,Scapy安装失败

我最近开始学习网络,我想安装scapy.我已经下载了最新版本(2.2.0),并且在我的计算机上有两个版本的python-2.6.1和3.3.2.我的操作系统是Windows 7 64位.

提取scapy并导航到终端中的正确文件夹后,我被指示运行"python setup.py install".我收到以下错误 -

文件"setup.py",第35行
os.chmod(fname,0755)
................................ ^
......................令牌无效

(对齐点)

我该如何解决这个问题?

python terminal installation scapy

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

NLTK查找错误

使用NLTK运行Python脚本时我得到了这个:

Traceback (most recent call last):
  File "cpicklesave.py", line 56, in <module>
    pos = nltk.pos_tag(words)
  File "/usr/lib/python2.7/site-packages/nltk/tag/__init__.py", line 110, in pos_tag
    tagger = PerceptronTagger()
  File "/usr/lib/python2.7/site-packages/nltk/tag/perceptron.py", line 140, in __init__
    AP_MODEL_LOC = str(find('taggers/averaged_perceptron_tagger/'+PICKLE))
  File "/usr/lib/python2.7/site-packages/nltk/data.py", line 641, in find
    raise LookupError(resource_not_found)
LookupError:
**********************************************************************
  Resource u'taggers/averaged_perceptron_tagger/averaged_perceptro
  n_tagger.pickle' not found.  Please use the NLTK Downloader to
  obtain the resource:  >>> nltk.download()
  Searched in:
    - '/root/nltk_data'
    - '/usr/share/nltk_data'
    - '/usr/local/share/nltk_data'
    - '/usr/lib/nltk_data'
    - '/usr/local/lib/nltk_data'
**********************************************************************
Run Code Online (Sandbox Code Playgroud)

有谁能解释这个问题?

python nltk python-2.7

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

C++后缀表达式未定义与未指定的行为

提前道歉,我知道评估订单的一般主题已经有很多SO问题.但是,看过它们之后,我想澄清一些我认为不等于重复的具体要点.假设我有以下代码:

#include <iostream>

auto myLambda(int& n)
{
    ++n;
    return [](int param) { std::cout << "param: " << param << std::endl; };
}

int main()
{
    int n{0};

    myLambda(n)(n);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

上面的程序在编译时输出"n:0".在这里我们有未指定的排序:它可以很容易地输出"n:1"发生了不同的评估顺序.

我的问题是:

  1. 在上面的最终函数调用(即lambda表达式调用)中,后缀表达式myLambda(0),其参数n和后续函数调用本身之间的排序关系究竟是什么?

  2. 以上是未定义或未指定行为的示例- 以及为什么(参考标准)?

  3. 如果我将lambda代码更改为[](int param) { std::cout << "hello" << std::endl }(即使结果独立于其参数,因此任何评估顺序决策,使行为确定性),上述2)的答案是否仍然相同?

编辑:我已将lambda参数名称从'n'更改为'param',因为这似乎导致了混淆.

c++ operator-precedence undefined-behavior language-lawyer c++14

24
推荐指数
2
解决办法
846
查看次数

将nullptr传递给std :: string :: assign是否有效?

我有一个返回指针和长度的函数,我想调用std::string::assign(pointer, length).clear当长度为零且指针可能为nullptr时,是否必须进行特殊情况(调用)?

C++标准说:

21.4.6.3 basic_string::assign

basic_string& assign(const charT* s, size_type n);
Requires: s points to an array of at least n elements of charT.
Run Code Online (Sandbox Code Playgroud)

那么如果n是零呢?什么是零字符数组,如何指向它?打电话有效吗?

s.assign(nullptr, 0);
Run Code Online (Sandbox Code Playgroud)

还是未定义的行为?

s当大小n为零时,libstdc ++的实现似乎不会取消引用指针,但这几乎不是保证.

c++ c++-standard-library language-lawyer

21
推荐指数
4
解决办法
1857
查看次数

采取行动的百分比机会

简单问题:percentage_chance = 0.36

if <don't know what>:
   #action here has 36% chance to execute
   pass
Run Code Online (Sandbox Code Playgroud)

我怎么解决这个问题?

python

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

在bokeh中嵌入散景应用程序

我正在拼命地将一个正在运行的散景小程序嵌入到烧瓶中,并且找不到合适的方法来执行此操作.我查看了所有示例,但我找不到一个包含更新数据的能力(最好的例子:sliders_applet).

如果我没弄错的话,我确实需要散景服务器才能更改数据(使用滑块等).以这种方式启动applet,例如:

bokeh-server --script sliders_app.py
Run Code Online (Sandbox Code Playgroud)

但我找不到合适的,或者至少是一种将sliders_app嵌入烧瓶的工作方式.由于应该可以使用多个applet,因此在散景服务器启动时指定一个小程序似乎并不干净.

我很乐意感谢任何帮助 - 散景看起来对我来说是一个很棒的工具.

python applet flask bokeh

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

如何在Scala Play Framework中对服务器启动执行操作?

我的目录中有一个配置文件servers.conf,conf/只要路由/servers被命中,我的ServerController就会读取该配置文件.这不具备性能,因为当文件不会更改时,它需要在每次连续命中时重新读取配置文件.此外,如果配置文件有问题,我可以尽快告诉用户,而不是在页面命中时抛出异常.

目前我在我的这个ServerController.scala:

case class Server(ip: String, port: String)

/**
  * This controller creates an `Action` to handle HTTP requests to the
  * application's server page.
  */
@Singleton
class ServerController @Inject() extends Controller {

  /**
    * Create an Action to render an HTML page with a the list of servers.
    * The configuration in the `routes` file means that this method
    * will be called when the application receives a `GET` request with …
Run Code Online (Sandbox Code Playgroud)

scala startup playframework playframework-2.5

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

如何防止`rust doc`向文档中添加依赖项?

我刚刚开始玩Rust,并试图为我编写的代码生成文档.当我发布时cargo doc,我看到了一些有点奇怪的东西.

21:53 $ cargo doc
   Compiling regex-syntax v0.2.2
   Compiling libc v0.2.2
   Compiling memchr v0.1.7
   Compiling aho-corasick v0.3.4
   Compiling regex v0.1.41
   Compiling my_project v0.0.1 (path/to/my_project)
Run Code Online (Sandbox Code Playgroud)

当我打开时my_project/target/doc/my_project/index.html,我注意到所有依赖项都包含在我的文档中:

那些该死的板条箱

我希望这些依赖项的文档对用户隐藏,因此我的文档仅显示如何使用我的代码.

我怎样才能做到这一点?

Cargo.lock

[root]
name = "my_project"
version = "0.0.1"
dependencies = [
 "regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "aho-corasick"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "memchr 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "libc"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "memchr" …
Run Code Online (Sandbox Code Playgroud)

rust rust-cargo rustdoc

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

如何正确定义lambda类型?

我使用=:=示例类型lambda来制作简单的最小例子.

=:= 类型带两个参数,我想在类型级别讨好一个.

我采取天真的实现,type Curry[G] = {type l[L] = L =:= G}但在实际使用中它会导致错误:

type X = Int
type Y = Int

type CurryInt[T] = T =:= Int
type Curry[G] = {type l[L] = L =:= G}
type CurrStatic = {type l[L] = L =:= Int}
object CurryObj {type l[L] = L =:= Int}

trait Apply[P[_], T]
implicit def liftApply[P[_], T](implicit ev : P[T]) = new Apply[P,T] {}

implicitly[Apply[CurryInt, Y]] // ok
implicitly[Apply[Curry[X]#l, Y]] // fails
implicitly[Apply[Curry[X]#l, Y]](liftApply) …
Run Code Online (Sandbox Code Playgroud)

scala type-inference implicits

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

Scikit Learn Multilabel分类:ValueError:您似乎正在使用传统的多标签数据表示

我正在尝试使用scikit学习0.17与anaconda 2.7的多标签分类问题.这是我的代码

import pandas as pd
import pickle
import re
from sklearn.cross_validation import train_test_split
from sklearn.metrics.metrics import classification_report, accuracy_score, confusion_matrix
from nltk.stem import WordNetLemmatizer
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.naive_bayes import MultinomialNB as MNB
from sklearn.pipeline import Pipeline
from sklearn.grid_search import GridSearchCV

traindf = pickle.load(open("train.pkl","rb"))

X, y = traindf['colC'], traindf['colB'].as_matrix()

Xtrain, Xtest, ytrain, ytest = train_test_split(X, y, train_size=0.7)

pip = Pipeline([
('vect', TfidfVectorizer(
                        analyzer='word',
                        binary=False,
                        decode_error='ignore',
                        dtype=<type 'numpy.int64'>,
                        encoding=u'utf-8',
                        input=u'content',
                        lowercase=True,
                        max_df=0.25,
                        max_features=None,
                        min_df=1,
                        ngram_range=(1, 1),
                        norm=u'l2',
                        preprocessor=None,
                        smooth_idf=True,
                        stop_words='english', …
Run Code Online (Sandbox Code Playgroud)

python machine-learning scikit-learn multilabel-classification

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