当前位置: 移动技术网 > IT编程>脚本编程>Python > 让Python输出更漂亮

让Python输出更漂亮

2018年02月07日  | 移动技术网IT编程  | 我要评论

倒打一耙什么意思,中国好声音海星,忘打一成语

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) #文件输出会有异常,需要异常处理

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网