小编Sva*_*sky的帖子

Eclipse:评论整个代码而不会被另一条评论缩短

假设我有以下代码(在C++中,但这对问题可能并不重要):

int main() {
    ....random code....
    /*This is a comment*/
    ....random code....
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

在eclipse中,当我想通过在代码之前和之后放入/*和*/来注释掉整个代码时,注释会在第3行的"这是注释"的末尾被*/缩短,所以其余代码未被注释.

/*    //<--overall comment starts here
int main() {
    ....random code....
    /*This is a comment*/    //<--overall comment ends here
    ....random code....
    return 0;
}
*/  //<--overall comment SHOULD end here
Run Code Online (Sandbox Code Playgroud)

任何人都知道解决这个问题的方法,或者我只需处理它或使用//评论......?

c++ eclipse comments block-comments

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

为什么 readline() 在 readlines() 之后不起作用?

在Python中,假设我有:

f = open("file.txt", "r")
    a = f.readlines()
    b = f.readline()
    print a
    print b
Run Code Online (Sandbox Code Playgroud)

print a将显示文件的所有行并且print b不显示任何内容。

同样反之亦然:

f = open("file.txt", "r")
    a = f.readline()
    b = f.readlines()
    print a
    print b
Run Code Online (Sandbox Code Playgroud)

print a显示第一行,但print b将显示除第一行之外的所有行。

如果 和a都是breadlines(),a将显示所有行并且b不显示任何内容。

为什么会出现这种情况?为什么两个命令不能独立工作?有解决方法吗?

python file readline readlines

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

标签 统计

block-comments ×1

c++ ×1

comments ×1

eclipse ×1

file ×1

python ×1

readline ×1

readlines ×1