小编Sam*_*Sam的帖子

IndentationError需要一个缩进块

这是代码:

def myfirst_yoursecond(p,q):

a = p.find(" ")
b = q.find(" ")
str_p = p[0:a]
str_q = p[b+1:]

if str_p == str_q:
    result = True
else:
    result = False
return result
Run Code Online (Sandbox Code Playgroud)

这是错误:

Traceback (most recent call last):
File "vm_main.py", line 26, in <module>
import main
File "/tmp/vmuser_ssgopfskde/main.py", line 22
result = False
^
IndentationError: expected an indented block
Run Code Online (Sandbox Code Playgroud)

我的代码出了什么问题?

python indentation

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

ctrl-d没有停止while(getchar()!= EOF)循环

这是我的代码.我用终端在ubuntu中运行它.当我CtrlD在终端输入(a )时,程序没有停止,而是继续等待我的输入.

CtrlD在unix中不等于EOF吗?

谢谢.

#include<stdio.h>

main() {
    int d;
    while(d=getchar()!=EOF) {
        printf("\"getchar()!=EOF\" result is %d\n", d);
        printf("EOF:%d\n", EOF);
    }
        printf("\"getchar()!=EOF\" result is %d\n", d);
}
Run Code Online (Sandbox Code Playgroud)

c unix eof

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

为什么c ++禁止隐式转换void*?

在C中,我们可以转换void*为任何其他指针.

但是C++禁止它.

int *a = malloc(4);
Run Code Online (Sandbox Code Playgroud)

导致此错误:

invalid conversion from ‘void*’ to ‘int*’ [-fpermissive]
Run Code Online (Sandbox Code Playgroud)

c ++中有潜在的危险吗?

有没有c ++的例子?

c c++

7
推荐指数
2
解决办法
1569
查看次数

android日历月从0开始

可能的重复:
为什么 Java 日历中的 1 月是 0?

android中的日历好像是从0开始的,为什么要这样设计呢?

final Calendar c = Calendar.getInstance();
mMonth = c.get(Calendar.MONTH);
Run Code Online (Sandbox Code Playgroud)

今天,mMonth 是 4。

java calendar

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

张量流的估计器如何加载模型的特定步骤而不是最新模型?

我们可以使用Estimator和保存模型的许多检查点RunConfig

classifiereval 200默认会使用最新步骤, 我可以加载ckpt-1吗?

my_checkpointing_config = tf.estimator.RunConfig(
    save_checkpoints_secs = 20*60,  # Save checkpoints every 20 minutes.
    keep_checkpoint_max = 10,       # Retain the 10 most recent checkpoints.
)
classifier = tf.estimator.DNNClassifier(
    feature_columns=my_feature_columns,
    hidden_units=[10, 10],
    n_classes=3,
    model_dir='models/iris',
    config=my_checkpointing_config)



$ ls -1 models/iris
checkpoint
events.out.tfevents.timestamp.hostname
graph.pbtxt
model.ckpt-1.data-00000-of-00001
model.ckpt-1.index
model.ckpt-1.meta
model.ckpt-200.data-00000-of-00001
model.ckpt-200.index
model.ckpt-200.meta
Run Code Online (Sandbox Code Playgroud)

tensorflow

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

内存泄漏是如何发生的?

这是代码,该程序导致内存泄漏.我不知道怎么回事?

#include <iostream>
#include <memory>
#include <stdexcept>
using namespace std;

void test(shared_ptr<string> &ptr, int num) {
    cout << "pass test:" << *ptr << " " << num << endl;
}

int fun() {
    throw new runtime_error("runtime error");
    return 0;
}

int main() {

    try {
      //  test(static_cast<shared_ptr<string> >(new string("hello")), fun());
      //  Solution
      shared_ptr<string> sps(new string("h"));
      test (sps, fun());
    } catch (runtime_error *e) {
        cout << e->what() << endl;
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我使用valgrind来测试内存泄漏.

==4726== 
==4726== HEAP SUMMARY:
==4726== …
Run Code Online (Sandbox Code Playgroud)

c++ memory-leaks

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

标签 统计

c ×2

c++ ×2

calendar ×1

eof ×1

indentation ×1

java ×1

memory-leaks ×1

python ×1

tensorflow ×1

unix ×1