加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

Python[print函数]

发布时间:2020-12-20 13:00:02 所属栏目:Python 来源:网络整理
导读:下面是 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)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读