我目前正在使用 Google Colab 以利用其免费 GPU。我试图修改我从 machinelearningmaster.com 复制和粘贴的代码。但是,每当我尝试添加新的代码行时,例如“print(”some words”),都会出现缩进错误。
我曾尝试在打印调用之前添加制表符或空格,但仍然出现错误。例如:space,space,print("some words") tab, tab ,print("some words")
我还检查了 colab 编辑器设置,目前缩进宽度设置设置为两个空格。
前三行是原代码的一部分,print语句是我的补充。我直接从 colab 编辑器复制并粘贴了它。在 Colab 中,所有四行都是对齐的。正如您在这里看到的,只有前三行对齐。我不知道发生了什么。
img_path = images_dir + filename
ann_path = annotations_dir + image_id + '.xml'
count=count+1
print("this is count: ", count)
Run Code Online (Sandbox Code Playgroud)
我希望这会打印 count 的值,但我收到一条错误消息告诉我: IndentationError: unindent does not match any external indentation level
我正在学习操作系统课程,我们被分配了Abraham Silberschatz Operating Systems第157页中的"Project 1 UNIX Shell and History Feature".我正在研究这个问题,并且遇到了一个有趣的GitHub代码.它包括一个"else if"声明,其中包含一个我以前从未见过的运算符(短划线 - ).我试图找出它的作用.
(链接)https://github.com/deepakavs/Unix-shell-and-history-feature-C/blob/master/shell2.c
else if (args[0][0]-'!' ==0)
{ int x = args[0][1]- '0';
int z = args[0][2]- '0';
Run Code Online (Sandbox Code Playgroud)
你可以在两个D数组中看到"ags [0] [0] - '!'"和"int x"和"int z"
有人能告诉我这叫什么,它在做什么?
谢谢
我正在尝试用 c 语言编写一个简单的边缘检测程序。我使用的是 Red Hat Enterprise Linux Server 7.7 (Maipo) 和 gcc 版本 4.8.5。
这是代码的开头:
#include <stdio.h>
#define size 200
int _tmain(int argc, _TCHAR* argv[])
{
char filein[size] = "./image.bmp";
FILE *fin;
fopen_s(&fin, filein, "rb");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我最初对 _TCHAR* 有很多问题,所以最终我用 char 替换了它,我不知道这以后是否会成为问题,但至少它编译并消除了这些错误。现在我收到隐式声明警告。我尝试通过添加其他#include 来修复它。
我尝试用以下方法修复它:
#include <stdio.h>
#include <errno.h>
#include <string.h>
#define size 200
int main(int argc, char* argv[])
{
char filein[size] = "./image.bmp";
FILE *fin;
fopen_s(&fin, filein, "rb");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但是,我仍然收到同样的警告,有人可以告诉我我做错了什么吗?
谢谢。
非常感谢,这有效!
#include <stdio.h>
#define size 200 …Run Code Online (Sandbox Code Playgroud)