功能列表
一、打印下载进度条
二、解决粘包模板
1、打印下载进度条
import time total_size = 20000 recv_size = 1024 recved_size = 0 sign = 1 while sign: if recved_size <= total_size: # 模拟网络延迟 time.sleep(1) # 实际接受数据长度 # data = client.recv(1024) # recv_size = len(data) percent = recved_size / total_size if percent > 1: percent = 1 sign = 0 num = percent * 50 print('\r[{:<50}]{}%'.format('=' * (int(num)), int(percent*100)), end='') recved_size += recv_size if recved_size > total_size: recved_size = total_size
2、解决粘包问题模板