print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
目录
builtins.py里的释义:
Prints the values to a stream, or to sys.stdout by default. Optional keyword arguments: file: a file-like object (stream); defaults to the current sys.stdout. sep: string inserted between values, default a space. end: string appended after the last value, default a newline. flush: whether to forcibly flush the stream.
Value
在2.X版本中,print可以不加括号。
在3.X版本及以后,print必须加括号。
Print在控制台里输出,VALUE可以是任何类型。
因为中间有一个"...",print函数里可以加无线个逗号分隔并都为Value的值。
print(1)
>>>1
print(1,2)
>>>1 2
print("123fff")
>>>123fff
print(True)
>>>True
Sep
sep表示分隔符。
print(1,2)>>>1 2
print(1,2,sep="|")>>>1|2
print(12,sep="|")>>>12
sep里的值可以分隔逗号之间的n个值。
print(1,2,3,4,sep="|")>>>1|2|3|4
print(1,2,sep="s]")>>>1s]2
End
End函数表示输入后的符号,默认为换行符(\n)
print(1)
print(2)
>>>1
>>>2
print(1,end="h")
print(2,end="e")
>>>1h2e
File
输出的位置(要求:必须有write函数)
默认:sys.stdout
print(1,end="")=std.stdout.write(1)
Flush
刷新,默认为False
[较为专业,一般不太用]
<我的第一个程序Hello,World.py>
print("Hello,World")