小编Are*_*ski的帖子

无法使用 numpy load() 加载数组

我无法从二进制文件加载数组。我究竟做错了什么?

pic = imread('headey-640.bmp')
save('test.in.npy', pic)
f = open('test.in.npy','r')
A = load(f)

---------------------------------------------------------------------------
ValueError: total size of new array must be unchanged
Run Code Online (Sandbox Code Playgroud)

python numpy

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

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

Ada对象"Train"在声明结束前不能使用

这段代码有什么问题?编译器说两件事,没有Run条目和Run接受与条目不匹配(两者似乎都是错误的),并且单独表示Train在声明之前不能使用(但它已经被声明).请向我解释发生了什么.

我对显示整个代码犹豫不决,但可以这样做.

type ItineraryType is array (0..255) of Integer;
type Train is record
    Label : Integer;
    Capacity : Integer;
    Maxspeed : Integer;
    Starts : Integer;
    Itinerary : ItineraryType;
    Stops : Integer;
    lock : access Mutex;
end record;

task type TrainThread is
    entry Run (train1:Train);
end;
task body TrainThread is
    train : Train;
begin
    accept Run (train1:Train) do
        train := train1;
    end;
end;

-- part of main
train1 := new TrainThread;
train1.Run(trains(i));
Run Code Online (Sandbox Code Playgroud)
main.adb:51:05: warning: no accept for entry "Run"
main.adb:52:17: object …
Run Code Online (Sandbox Code Playgroud)

concurrency ada syntax-error task

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

Python什么代码约定将参数拆分成行?

将参数分成行的惯例是什么?是否有PEP对此进行制裁?我没有在PEP8中找到它.

file_like = f(self,
              path,
              mode=mode,
              buffering=buffering,
              encoding=encoding,
              errors=errors,
              newline=newline,
              line_buffering=line_buffering,
              **kwargs)
Run Code Online (Sandbox Code Playgroud)

python coding-style python-2.7

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

struct.unpack(struct.pack(float))有舍入错误?

在测试我的库Construct时,我发现在构建数字时测试失败然后解析回浮点数.浮点数不能完全表示为内存浮点数吗?

In [14]: d = struct.Struct("<f")

In [15]: d.unpack(d.pack(1.23))
Out[15]: (1.2300000190734863,)
Run Code Online (Sandbox Code Playgroud)

python floating-point pack

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

Golang从stdin行读取多个字段

$ echo "A 1 2 3 4" | go run test.go 
entire:  A
next field:  A
Run Code Online (Sandbox Code Playgroud)

我需要从标准输入中读取几行,例如“ A 1 2 3 4”(代码现在只占一行),并且出了点问题。Scanln应该阅读整行,并Fields用换行符分隔?为什么Scanln只读一个字?

package main

import (
    "fmt"
    "strings"
)

func main() {
    var line string
    fmt.Scanln(&line)
    fmt.Println("entire: ",line)
    for _,x := range strings.Fields(line) {
        fmt.Println("next field: ",x)
    }
}
Run Code Online (Sandbox Code Playgroud)
$ echo "A 1 2 3 4" | go run test.go 
entire:  A
next field:  A
Run Code Online (Sandbox Code Playgroud)

stdin split scanf go

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

如何检查 Box 是否为空指针?

我想使用指针或其他东西来实现堆栈。如何检查 aBox是否为空指针?我看过一些代码Option<Box<T>>Box<Option<T>>,但我不明白这一点。就我而言,这是:

struct Node {
    value: i32,
    next: Box<Node>,
}

struct Stack {
    top: Box<Node>,
}
Run Code Online (Sandbox Code Playgroud)

null pointers rust box

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

"推"的操作数类型不匹配

我需要有关使用ASSEMBLY部件的C代码的帮助.GCC编译程序集有问题,错误:

$ make
gcc -Wall -g -std=c99 -pedantic   -c -o sthread.o sthread.c
sthread.c: In function ‘sthread_create’:
sthread.c:159:57: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith]
     t->context = __sthread_initialize_context(t->memory + DEFAULT_STACKSIZE, f, arg);
                                                         ^
gcc -Wall -g -std=c99 -pedantic   -c -o queue.o queue.c
as -g  -o glue.o glue.s
glue.s: Assembler messages:
glue.s:32: Error: operand type mismatch for `push'
<wbudowane>: polecenia dla obiektu 'glue.o' nie powiod?y si?
make: *** [glue.o] B??d 1
Run Code Online (Sandbox Code Playgroud)

有问题的代码:

__sthread_switch:
    # preserve CPU state on the …
Run Code Online (Sandbox Code Playgroud)

c assembly gcc x86-64

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