小编Ros*_*one的帖子

在unix上找不到c ++库

我写了一个简单的c ++程序test.cpp:

#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;
  cout << s << endl;
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

为什么runnning gcc test.cpp -o mytest会给我这些错误,还有更多?

Undefined symbols for architecture x86_64:
  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()", referenced from:
      _main in cc8rGYVq.o
  "std::cin", referenced from:
      _main in cc8rGYVq.o
Run Code Online (Sandbox Code Playgroud)

c++ unix

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

"写入"unix系统调用失败

下面的第三行返回-1.我该怎么做才能调试?

void *zeroed_block = calloc(512, 1);
lseek(3, sectorNum * 512, SEEK_SET);
return write(fd, zeroed_block, 512); /* This line returns -1 */
Run Code Online (Sandbox Code Playgroud)

当我打印由write(使用perror)引起的错误时原因是"文件描述符错误"

这是我打开文件描述符的代码:

char *diskpath = argv[optind]; – Rose Perrone 1 min ago edit 
int fd = diskimg_open(diskpath, (removeFlag == NULL)); 

int
diskimg_open (char *pathname, int readOnly)
{
  return open(pathname, readOnly ? O_RDONLY : O_RDWR);
}
Run Code Online (Sandbox Code Playgroud)

在这三行代码之外,每次使用它时,打开文件描述符的工作都是可靠的.

我在Mac OS上,所以这里是输出dtruss,如所要求的:

SYSCALL(args)        = return
open(".\0", 0x0, 0x1)        = 3 0
fstat64(0x3, 0x7FFF63557420, 0x0)        = 0 0
fcntl(0x3, 0x32, 0x7FFF635576A0)         = …
Run Code Online (Sandbox Code Playgroud)

c unix

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

TypeError:"_ _ init __()得到关键字参数'name'的多个值"

当我调用这个构造函数时,为什么我在标题中出现错误?

我打电话User(**args)给以下字典args:

{'name': u'Rose Perrone', 'ipAddress': '127.0.0.1', 'email': u'hi@gmail.com'}
Run Code Online (Sandbox Code Playgroud)

这是构造函数:

def __init__(name,
             ipAddress,
             password=None,
             email=None,
             deleted=None,
             includePromoted=None,
             explicit=None):
Run Code Online (Sandbox Code Playgroud)

python

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

拦截超链接点击

我正在尝试拦截此链接上的点击次数:

<a id="test-button" href="#">Test</a>
Run Code Online (Sandbox Code Playgroud)

用这个js:

(function() {
    $('#test-button').click(function (event) {
        console.log("This code never gets called.")
        event.preventDefault();
        $('#alert-placeholder').html(['<div class="alert"><a class="close"',
                                      'data-dismiss="alert">×</a>',
                                      '<span>"+message+"</span></div>'].join())
        return false;
    })
    console.log("yes, this code loads");
    debugger;
})();
Run Code Online (Sandbox Code Playgroud)

但是URL '#'加载并且click()函数中的代码不会运行.我错过了什么?

我在使用bootstrap的烧瓶应用程序中使用此代码.

javascript

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

最终防护中的解析错误(不正确的缩进或括号不匹配)

我在下面的代码中得到了这个错误,但是当我注释掉最后一行时,错误消失了.最后或倒数第二行有什么问题?

parse error (possibly incorrect indentation or mismatched brackets)
Run Code Online (Sandbox Code Playgroud)

.

-- | Recursively builds the selector
constructSelector :: String -> Selector -> Maybe [String] -> Maybe [String] -> Selector
constructSelector docType selector inputWords tagsSoFar =
    case docType of
        "tag" -> []
        "todo" -> case inputWords of
                    Nothing -> selector
                    -- when there are no args left to examine, check if we've
                    -- recursively accumulated a list of tags
                    Just ws | ws == [] -> case tagsSoFar of
                                            Nothing -> …
Run Code Online (Sandbox Code Playgroud)

haskell

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

将PIL图像转换为numpy数组

我想将PIL图像转换为numpy数组.Numpy的asarray功能只是将图像放在一个0维数组中.

(Pdb) p img
<PIL.Image._ImageCrop image mode=RGB size=1024x0 at 0x106953560>
(Pdb) img.getdata()
<ImagingCore object at 0x104c97b10>
(Pdb) np.asarray(img.getdata())
array([], dtype=float64)
(Pdb) np.asarray(img)
array(<PIL.Image._ImageCrop image mode=RGB size=1024x0 at 0x106953560>, dtype=object)
(Pdb) np.asarray(img).shape
()
(Pdb) np.asarray(img, np.uint8)
*** SystemError: error return without exception set
Run Code Online (Sandbox Code Playgroud)

关于类似SO问题的解决方案不起作用.

python numpy python-imaging-library

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

将3d numpy数组(RGB图像)转换为布尔数组的快速方法

我怎样才能加快这个功能?512x512图像需要1.3秒.

def bool_map(image):
  '''
  Returns an np.array containing booleans,
  where True means a pixel has red value > 200.
  '''
  bool_map = np.zeros(image.shape, dtype=np.bool_)
  for row in range(image.shape[0]):
    for col in range(image.shape[0]):
      if image[row, col, 0] > 200:
        bool_map[row, col] = True
  return bool_map
Run Code Online (Sandbox Code Playgroud)

python numpy

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

标志未在python-gflags中设置

我在这个例子中如何滥用gflags?在命令行上设置标志不会覆盖默认值,但是当我根据需要设置标志并且不使用默认值(注释代码)时,它被设置(to False)就好了.

import gflags
from gflags import FLAGS

#gflags.DEFINE_bool('use_cache', None, '')
#gflags.MarkFlagAsRequired('use_cache')

gflags.DEFINE_bool('use_cache', True, '')

if __name__ == '__main__':
  if FLAGS.use_cache == True:
    print 'use_cache == True'
  else:
    print 'use_cache == False'
Run Code Online (Sandbox Code Playgroud)

.

~ python testflags.py --use_cache=False
use_cache == True
~ python testflags.py --help
use_cache == True
Run Code Online (Sandbox Code Playgroud)

python gflags

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

Matlab说'find'没有在函数中定义

在我的命令窗口中,我可以执行find([0 1 0]),但是当我在函数中运行find时x = find([0 1 0]),编译器告诉我find没有定义.为什么会这样?

错误是:

??? Error: File: frequentTuples.m Line: 12 Column: 21
 "find" previously appeared to be used as a function or command, conflicting with its
 use here as the name of a variable.
 A possible cause of this error is that you forgot to initialize the
 variable, or you have initialized it implicitly using load or eval.
Run Code Online (Sandbox Code Playgroud)

这是代码.错误发生在for循环的第二行.

function [ tuples ] = frequentTuples( k, candidates, transactions, min_support  ) …
Run Code Online (Sandbox Code Playgroud)

matlab

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

为什么制表完成(wildmenu)不起作用?

我的.vimrc包含:

set wildmenu                    " show list instead of just completing
set wildmode=list:longest,full  " command <Tab> completion, list matches, then longest common part, then all.
set wildignore+=.cache,.gem,.ivy2,.extras.bash,.themes
set wildignore+=.subversion,.subversion_IDEA
set wildignore+=.Trash
set wildignore+=Desktop,Documents,Downloads
set wildignore+=Library,Movies,Pictures
set wildignore+=spf13vim2
set wildignore+=.CFUserTextEncoding,.DS_Store
set wildignore+=.bash_history,.extra.bash,.irb-history
set wildignore+=.lesshst,.mysql_history,.pry_history
set wildignore+=.reviewboard-cache,.rnd,.sbt.cache.lock
set wildignore+=.scala_history,.sqlite_history,.viminfo
set wildignore+=*.o,*.obj,.git,vendor/rails/**,vendor/gems/**
set wildignore+=*.swp
Run Code Online (Sandbox Code Playgroud)

你可以在这里找到我的完整vimrc .当我在vim中编辑文件时,命中tab产生空格,但没有自动完成.

vim

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

标签 统计

python ×4

numpy ×2

unix ×2

c ×1

c++ ×1

gflags ×1

haskell ×1

javascript ×1

matlab ×1

python-imaging-library ×1

vim ×1