当我在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中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)