python

转化时间戳

time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(int(data["starttime"])))

多线程queue


class
GetMemInfoThread(threading.Thread): def __init__(self, node_queue, result_queue, compute_list): threading.Thread.__init__(self) self.nq = node_queue self.rq = result_queue self.compute_list=compute_list def run(self): while not self.nq.empty(): node = self.nq.get() print "start ",node meminfo = get_compute_node_memroy_info(node, self.compute_list) print "end ",node if isinstance(meminfo, ComputeNodeMemoryInfo): self.rq.put(meminfo) def get_all_compute_node_memory_info_mt(controller, treadnum=1): print "get compute nodes list", controller compute_list = get_compute_nodes_list(controller) print "get compute node:", len(compute_list) node_queue = Queue.Queue() result_queue = Queue.Queue() for node in compute_list: node_queue.put(node) threads = [] for t in xrange(treadnum): threads.append(GetMemInfoThread(node_queue, result_queue, compute_list)) print "start thread", treadnum starttime = time.time() for t in threads: t.start() for t in threads: t.join() print "done:",time.time()-starttime print "get results:",result_queue.qsize()

docstring

https://www.datacamp.com/community/tutorials/docstrings-python#comments

 排序

list1 = [3,5,-4,-1,0,-2,-6] sorted(list1, key=lambda x: abs(x))

转载于:https://www.cnblogs.com/QQQmadNULL/p/9895624.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值