相关疑难解决方法(0)

如何在没有换行或空格的情况下打印?

问题出在标题中.

我想在做到这一点 .我想在中的这个例子中做些什么:

#include <stdio.h>

int main() {
    int i;
    for (i=0; i<10; i++) printf(".");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出:

..........
Run Code Online (Sandbox Code Playgroud)

在Python中:

>>> for i in xrange(0,10): print '.'
.
.
.
.
.
.
.
.
.
.
>>> for i in xrange(0,10): print '.',
. . . . . . . . . .
Run Code Online (Sandbox Code Playgroud)

在Python中print会添加一个\n或一个空格,我该如何避免呢?现在,这只是一个例子.不要告诉我,我可以先构建一个字符串然后打印它.我想知道如何"附加"字符串stdout.

python newline python-2.x

1760
推荐指数
20
解决办法
178万
查看次数

标签 统计

newline ×1

python ×1

python-2.x ×1