小编Ama*_*man的帖子

Python 2.7.3:Sep参数显示错误

当我在Python 2.7.3中使用sep参数时,它显示错误

例如:-

      >>>print ("Hello","World",sep ="**")
           File "<stdin>", line 1
           print ("Hello","World",sep ="**")
                           ^
          SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

python python-2.7

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

如何避免打印功能中的新行?

在Python中print,如果我们想在一行中打印整个语句然后应该使用什么,那么函数会自动在语句后面换行.

例如:

>>> for number in range(1,6):
...     for k in range (0,number):
...             print ("*")
... 
Run Code Online (Sandbox Code Playgroud)

我得到以下输出:

*
*
*
*
*
*
*
*
*
*  
*
*
*
*
*
Run Code Online (Sandbox Code Playgroud)

虽然我需要这个:

*
**
***
****
*****
Run Code Online (Sandbox Code Playgroud)

python printing

0
推荐指数
2
解决办法
206
查看次数

标签 统计

python ×2

printing ×1

python-2.7 ×1