小编hal*_*lex的帖子

java中的空指针异常字符串2d数组

public String[][] fetchData()
{
    String[][] data = null;
    int counter = 0;
    while (counter < 10){
        data[counter] = new String[] {"abc"};
        counter++;
    }
    return data;
}
Run Code Online (Sandbox Code Playgroud)

在此循环中获取错误.请让我知道我错在哪里

java arrays string 2d

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

调整opencv中的图片大小?

我正在opencv写一个面部表演程序.这是下面的错误代码:

result = img[rects[0]:rects[1], rects[2]:rects[3]] 
result = cv2.resize(result, (100,100)) 
Run Code Online (Sandbox Code Playgroud)

img是我们的原始图片,第一步是将我们对结果感兴趣.第二步是调整为100*100像素.

错误是:

result = cv2.resize(result, (100,100))
error: ..\..\..\src\opencv\modules\imgproc\src\imgwarp.cpp:1725: error: (-215) ssize.area() > 0
Run Code Online (Sandbox Code Playgroud)

希望可以有人帮帮我.非常感谢.

python opencv

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

HashSet存储相等的对象

下面是从对象列表中查找重复对象的代码.但由于某种原因,hashset甚至存储了相等的对象.

我肯定错过了一些东西,但是当我检查hashset的大小时,它出来了5.

import java.util.ArrayList;
import java.util.HashSet;


public class DuplicateTest {

public static void main(String args[]){
    ArrayList<Dog> dogList = new ArrayList<Dog>();
    ArrayList<Dog> duplicatesList = new ArrayList<Dog>();
    HashSet<Dog> uniqueSet = new HashSet<Dog>();

    Dog a = new Dog();
    Dog b = new Dog();
    Dog c = new Dog();
    Dog d = new Dog();
    Dog e = new Dog();

    a.setSize("a");
    b.setSize("b");
    c.setSize("c");
    d.setSize("a");
    e.setSize("a");

    dogList.add(a);
    dogList.add(b);
    dogList.add(c);
    dogList.add(d);
    dogList.add(e);

    if(a.equals(d)){
        System.out.println("two dogs are equal");
    }
    else System.out.println("dogs not eqal");

    for(Dog dog : dogList){
        uniqueSet.add(dog); …
Run Code Online (Sandbox Code Playgroud)

java equals hashset duplicate-removal

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

如何使用python从气球弹出窗口读取文本?

我正在使用蓝牙将一个约500MB的大文件从一个系统传输到另一个系统。在这段时间里,我将看到一个气球弹出窗口,上面显示“ Bluetooth Connection”(蓝牙连接),其内容是模式已更改为高速模式。我想使用python在变量中获取此文本。关于如何从气球弹出窗口中读取文本的任何线索?

希望尽快得到答复。

关于辛

python bluetooth balloon-tip

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

试图获得对角线总和

试图在#6创建的列表的#7中对角地获得总和.所以说清单是这个[[2,3,1],[1,1,1],[5,6,4]]总和将是2 + 1 + 4

#6

def randomlists(s):
    b=s
    list1 = []
    while s>0:
        sublist = []
        for x in range(0,b):
            sublist.append(randrange(-100,101))
        list1.append(sublist)
        s-=1
    return list1
#print(randomlists(5))
#7

def diagonalsum(x):
    a=randomlists(x)
    count=0
    print (a)
    for b in a:
        while count<x:
            d=a[0]
            b=a[1]
            c=a[2]
            print (a[(count)])
            count+=1
        return d+b+c
print (diagonalsum(3))
Run Code Online (Sandbox Code Playgroud)

python sum python-2.7 diagonal

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

树枝和JavaScript

我正在创建一个显示图表的页面,具体取决于在组合框中选择的类型

<div id="chartdiv"></div>

<select name="graphe" id="identifiantDeMonSelect">
<option value="Column2D">Column2D
<option value="Column3D">Column3D
<option value="Pie3D">Pie3D
<option value="Pie2D">Pie2D
</select>
<input type="submit" value="Afficher" onclick="ajax()">


<script type="text/javascript">
function ajax(){
    var xhr

    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if (xhr !=null)  {
    xhr.onreadystatechange = function() { type1(xhr); };
    xhr.open("GET", "{{ path('Ajax')}}", true);
    xhr.send(null);
    } else {

     alert("The XMLHttpRequest not supported");

  }}

function type1(xhr){
            var docXML= xhr.responseText;
            var val_type = getSelectValue('identifiantDeMonSelect');
            var type = val_type+"";
            var str="{{ …
Run Code Online (Sandbox Code Playgroud)

javascript twig

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

在更改其中一个元素的同时,从现有元组创建新元组?

我有一个像这样的元组列表:

[('Ben', '5 0 0 0 0 0 0 1 0 1 -3 5 0 0 0 5 5 0 0 0 0 5 0 0 0 0 0 0 0 0 1 3 0 1 0 -5 0 0 5 5 0 5 5 5 0 5 5 0 0 0 5 5 5 5 -5'),
 ('Moose', '5 5 0 0 0 0 3 0 0 1 0 5 3 0 5 0 3 3 5 0 0 0 …
Run Code Online (Sandbox Code Playgroud)

python

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

使用Arrays.asList的优点和缺点

我想知道使用的利弊Arrays.asList.我在代码中使用它时遇到了问题.

另外,我想知道在不使用的情况下将数组转换为数组列表(集合)的最佳方法 Arrays.asList

java arrays collections

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

删除方括号、逗号和单引号?

Python 3。我试图返回该函数,以便它需要一个单词并将其转换为 Cow Latin。我想在运行函数时去掉方括号、逗号和单撇号。

我的职能是:

alpha = list("bcdfghjklmnpqrstvwxyz")
def cow_latinify_word(word):
    if word[0].lower() in alpha:
        lista = (word.lower())
        return lista[1:] + lista[0] + "oo"
    else:
        return word + "moo"

def cow_latinify_sentence(sentence):
    words = sentence.split();
    return [cow_latinify_word(word) for word in words]
Run Code Online (Sandbox Code Playgroud)

当我测试该功能时

cow_latin = cow_latinify_sentence("Cook me some eggs")
print(cow_latin)
Run Code Online (Sandbox Code Playgroud)

我得到['ookcoo', 'emoo', 'omesoo', 'eggsmoo']但我想要ookcoo emoo omesoo eggsmoo

python python-3.x

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

当标记更改时,选择第n个类型为(1)的第一个实例的CSS选择器失败

这让我很难过......

在这看到JSBIN

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<style>
    .slide-nav:nth-of-type(1) { color:red } /* this should select the number 1 */
</style>
</head>
<body>

  <div class="image">
    <span class="slide" data-order="4" rel="content-images/teta.jpg" ></span>
    <span class="slide" data-order="3" rel="content-images/champ.jpg" ></span>
    <span class="slide" data-order="2" rel="content-images/clouds.jpg" ></span>
    <img class="slide initial" data-order="1" src="content-images/air.jpg" />
    <span class="spinner"></span>

    <!--  
    delete this line to comment the two arrow links -->
    <a class="arrow next" href="javascript:void(0)">&rarr;</a>
    <a class="arrow prev" href="javascript:void(0)">&larr;</a>
    <!-- -->

    <a class="slide-nav on" href="javascript:void(0)" rel="1">1</a>
    <a class="slide-nav" …
Run Code Online (Sandbox Code Playgroud)

html css css-selectors

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

C#变量,方法,参考练习

我在C#上做了一个练习,这里是:

class Program
{
    static double funk(int a, ref int b)
    {
        double c = a + b;
        a = 5;
        b = a * 3;
        return c;
    }

static void Main(string[] args)
{
    int a = 1, b = 2;
    Console.WriteLine(funk(a, ref b));
    Console.WriteLine(a);
    Console.WriteLine(b);
    Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)

因此,当我运行代码时结果非常清楚,它给了我:

3
1
15
Run Code Online (Sandbox Code Playgroud)

我现在的问题是,15和3来自哪里?

c#

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