1、print 的应用
print(1,2,3,4,5,sep="*") #sep是指定多个要打印的内容之间的分隔符 # 1*2*3*4*5 print(1,2,sep=",") #print("%s,%s"%(1,2)) # 1,2,3 print(1,end="") print(2) #12 print(1,end=",") print(2) # 1,2 f=open("a","w") print("abc ",file=f) #将abc写入文件a print(2)
进度条的例子
import time for i in range(0,101,2): time.sleep(0.2) char_num=i//2 if i==100: per_str=" %s%%:%s "%(i,"|"*char_num) else: per_str=" %s%%:%s"%(i,"|"*char_num) print(per_str,end="",flush=True) print("再见")
import time for i in range(0,101,2): time.sleep(0.2) char_num=i//2 per_str=" %s%%:%s "%(i,"*"*char_num)if i ==100 else" %s%%:%s"%(i,"*"*char_num) print(per_str,end="",flush=True)
字体颜色的输出:
print(" 33[显示方式;前景色;背景色m") 格式
print("