下面是 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)