小编Hei*_*h-B的帖子

为什么在打印时附加一个列表显示?

当我使用以下代码添加列表时.

a = [1, 2, 3, 4]
print a

a.append(a)
print a
Run Code Online (Sandbox Code Playgroud)

我期待输出是......

[1, 2, 3, 4]
[1, 2, 3, 4, [1, 2, 3, 4]]
Run Code Online (Sandbox Code Playgroud)

但它是这样的......

[1, 2, 3, 4]
[1, 2, 3, 4, [...]]
Run Code Online (Sandbox Code Playgroud)

为什么?

python list python-2.7 python-3.x

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

无法编译C++程序

这是代码....

#include <iostream>

int main()
{
    cout << "WELCOME TO C++ PROGRAMMING";
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

当我去终端并通过命令..

g++ hello.cpp
Run Code Online (Sandbox Code Playgroud)

表明...

hello.cpp: In function ‘int main()’:
hello.cpp:4:2: error: ‘cout’ was not declared in this scope
  cout << "WELCOME TO C++ PROGRAMMING";
  ^
hello.cpp:4:2: note: suggested alternative:
In file included from hello.cpp:1:0:
/usr/include/c++/4.8/iostream:61:18: note:   ‘std::cout’
   extern ostream cout;  /// Linked to standard output
Run Code Online (Sandbox Code Playgroud)

那是什么原因?我该怎么办?

c++ linux terminal ubuntu

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

标签 统计

c++ ×1

linux ×1

list ×1

python ×1

python-2.7 ×1

python-3.x ×1

terminal ×1

ubuntu ×1