发布时间:2019-09-13 09:26:30编辑:auto阅读(2421)
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) #文件输出会有异常,需要异常处理
上一篇: Python学习记录-多进程和多线程
下一篇: zabbix实现Python邮件报警
50996
50379
40994
37861
32327
29219
28102
22932
22900
21227
1091°
1782°
1453°
1392°
1666°
1474°
2132°
3693°
3627°
2549°