python日常.md
Python日常
IP处理
import IPy.IP
oip = "8.8.2.32/30"
ip: IPy.IP = IPy.IP(oip, make_net=True)
if ip.version() != 4:
return
start = ip.net()
end = ip.broadcast()
mask = oip.split('/')[1]
多线程处理
from concurrent.futures import ThreadPoolExecutor, as_completed
def bind(serial, account):
// do something ...
with ThreadPoolExecutor(max_workers=10) as t:
obj_list = []
for serial, account in DATA:
obj = t.submit(bind, serial, account)
obj_list.append(obj)
for future in as_completed(obj_list):
continue