print函数
print(…)
print(value, …, sep=’ ‘, end=’\n’, file=sys.stdout, flush=False)
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.
print(a+b)&print(a*5)
案例1
a = 1
b = 2
print(a+b)
print(a,b)
c = "one"
d = "two"
print(c+d)
print(c,d)
e = "haha"
print(e*5)
输出
3
1 2
onetwo
one two
hahahahahahahahahaha
print(空格制表换行)
案例2
f = "alpha!"
g = " alpha!"
h = "\talpha!"
i = "\nalpha!"
print(f)
print(g)
print(h)
print(i)
输出
alpha!
alpha!
alpha!
alpha!
print(三引号)
案例3
print("""
There's something going on here.
with the three double-quotes.
we'll be able to type as much as we like.
even 4 lines we want, or 5.
""")
输出(这里空行也是输出的一部分)
There's something going on here.
with the three double-quotes.
we'll be able to type as much as we like.
even 4 lines we want, or 5.