让Python输出更漂亮-Print 输出

print 默认输出是换行的,如果要实现不换行需要在变量末尾加上 end=""

 

student_age=18

print("学生的年龄为:",student_age)

#print("学生的年龄为:"),print(student_age)中间不换行

 

 

#print执行完后默认换行

print("hello,world!",end="\n")

print("hello,world!",end="") # 不换行

print("hello,world!",end="")




print("Abby","Candy","Tina","Sandy",sep="==")

 

sep 分隔符

如:

money 121

print("本次消费金额为:",money,sep="$")





print还可以把内容输出到文件

str01 "本次消费金额为:$128"

file01 open("d:\sales.txt","w")

print(str01,file=file01) #文件输出会有异常,需要异常处理




























评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值