python之print

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.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值