#coding=utf-8
import time
import base64
import getopt
import sys
import threading
import random
import string
import os
def base64_cal():
str = 'admin'
str = str.encode('utf-8')
# 加密
bs64 = base64.b64encode(str)
# 解密
debs64 = base64.b64decode(bs64)
print(debs64.decode("utf-8"))
# base32bit加密
bs32 = base64.b32encode(str)
debs32 = base64.b32decode(bs32)
print(debs32.decode("utf-8")) def enterParams():
opts, args = getopt.getopt(sys.argv[1:], '-h-c:f:', ['help', 'concurrent=', 'file='])
concurrent_data=None
filename=None
for opt_name, opt_value in opts:
print(opt_name,opt_value)
if opt_name in ('-h', '--help'):
usage()
sys.exit()
if opt_name in ('-c', '--concurrent'):
if type(opt_value).__name__=='str':
concurrent_data=opt_value
if opt_name in ('-f', '--file'):
filename = opt_value
# else:
# # return None
# raise TypeError("enter param {} not file's path".format(opt_value)) return concurrent_data,filename def usage():
str="--help:\n\t-c : concurrent TotalData\n\t -f: filename's path\n--example:" \
"\n\tpython testfile.py -c 1000000 -file=./res/testPython.txt"
print(str) class ConcurrentIdSample(threading.Thread):
def __init__(self,func,args=()):
self.func=func
self.args=args
threading.Thread.__init__(self)
def run(self):
self.result = self.func(*self.args)
def get_result(self):
try:
return self.result
except Exception:
return None def func(*args):
# print(time.asctime())
return ''.join(random.sample(string.hexdigits,random.randint(*args))) def concurrent_execute(concurrent_data):
pool=[]
samplesList=[]
for i in range(concurrent_data):
thread_sample=ConcurrentIdSample(func,(16,20))
pool.append(thread_sample)
thread_sample.start()
for thread in pool:
thread.join()
samplesList.append(thread.get_result())
return samplesList def outPut():
st=time.time()
concurrent_data,filename=enterParams()
res=concurrent_execute(concurrent_data)
end=time.time()
during=end-st
print(len(res),"\nmake {} datas time cost {}".format(concurrent_data,during),'\n')
if __name__ == '__main__':
enterParams()

  

最新文章

  1. FineReport实现根据点击次数奇偶性排序的方法
  2. C# DateTime转Json汇总
  3. SharePoint Server 2013开发之旅(三):为SharePoint Server配置App开发、部署、管理环境
  4. userprofile同步用户失败的原因和解决方案
  5. R-处理数据对象的实用函数
  6. Office 开发版本号与版本对应关系
  7. hdu5876 Sparse Graph(补图最短路 bfs)
  8. CELERY里,这个WARNING如何消除?
  9. MySQL--连接属性
  10. MTU & MSS 详解记录(转)
  11. C#管理控制IIS7的方法
  12. A2D规则引擎
  13. svg制作风车旋转
  14. 6个重要的.NET概念: - 堆栈,堆,值类型,引用类型,装箱和拆箱(转)
  15. Ubuntu16.04下OpenCV调用笔记本摄像头
  16. windows下apache+https环境配置
  17. ORACLE 数据库管理
  18. python slenium 中CSS定位
  19. day2 --> pyc 文件
  20. ubuntu 16.04 配置静态ip 后默认的网卡eno1变成eth0了不能联网的问题解决

热门文章

  1. 265. 粉刷房子 II
  2. ColorPix——到目前为止最好用的屏幕取色器
  3. [Leetcode] 攻略计划
  4. Vue2.0 中,“渐进式框架”和“自底向上增量开发的设计”这两个概念是什么?(转)
  5. css颜色+透明度的写法
  6. 「JSOI2015」地铁线路
  7. php 接口获取公网ip并获取天气接口信息
  8. python学习之matplotlib绘制动图(FuncAnimation()参数)
  9. VS常用快捷键(2012)
  10. opencv python:图像金字塔