进度条 & 随机码生成

#进度条#

import time

def make_progress(percent,width=50):
if percent > 1:
percent=1
show_str=('[%%-%ds]' %width) %(int(percent * width) * '=')
print('\r%s %s%%' %(show_str,int(percent * 100)),end='')

total_size=113021
recv_size=0
while recv_size < total_size:
time.sleep(0.5)
recv_size+=1024
percent=recv_size / total_size
make_progress(percent)




#随机码生成#
import random
def make_size(n):
res=''
for i in range(n):
num=str(random.randint(0,9))
s=chr(random.randint(65,90))
res+=random.choice([num,s])
return res
print(make_size(5))



猜你喜欢

转载自www.cnblogs.com/rongge95500/p/9209927.html