python - A multi-threading novice would like to ask how to implement multi-threaded printing with such an IP?
PHPz
PHPz 2017-05-27 17:39:49
0
2
871
def hanshu(b):
    print(b)

a="192.168.1.1-3"
for ip in a.split(','):
    if '-' in ip:
        s1, s2 = ip.rsplit('.', 1)
        start, end = map(int, s2.split('-'))
        for num in range(start, end+1):
            b=s1+'.'+str(num)
            hanshu(b)
    else:
        hanshu(ip)
PHPz
PHPz

学习是最好的投资!

reply all(2)
黄舟
https://pypi.python.org/pypi/IPy/

Use this module, your code will not be so ugly, and
split(",") is written wrong

黄舟

The threading module is used for multi-threading. I don’t quite understand what you want

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template