Python[print函数]

Python[print函数],第1张

概述下面是 print函数的一种用法,用逗号隔开,可在同一行打印不同类型的数据。 x = input(‘请你输入被除数:‘) y = input(‘请你输入除数:‘) z = float(x)/float(y) print(x,‘/‘,y,‘=‘,z) ###########################################################################

下面是 print函数的一种用法,用逗号隔开,可在同一行打印不同类型的数据。
x = input(‘请你输入被除数:‘)
y = input(‘请你输入除数:‘)
z = float(x)/float(y)
print(x,‘/‘,y,‘=‘,z)

#########################################################################################

>>> help(print) #python查看帮助的其中一种方式

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打印倒计时

import time

print("倒计时程序")

for x in range(5,-1,-1):

  mystr = "倒计时" + str(x) + "秒"

  print(mystr,end = "")

  print("\b" * (len(mystr)*2),end = "",flush=True) #\b 退格 (len(mystr)打印len(mystr)字符串长度 1个中文字符 = 2个英文字符(占位),所以*2

  time.sleep(1)

总结

以上是内存溢出为你收集整理的Python[print函数]全部内容,希望文章能够帮你解决Python[print函数]所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1195741.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存