亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

python - Solving IP segmentation problem
曾經(jīng)蠟筆沒有小新
曾經(jīng)蠟筆沒有小新 2017-05-18 10:45:55
0
2
1047

There is such an ip: "192.168.1.1-5,192.168.1.10-15"
I want it to be output as:
192.168.1.1
192.168.1.2
192.168.1.3
What's there? Is it a good idea? I can use text processing in Yi Language to implement this. I’m not very familiar with Python yet, so I’d like to ask someone to give me some ideas.

曾經(jīng)蠟筆沒有小新
曾經(jīng)蠟筆沒有小新

reply all(2)
PHPzhong
a = "192.168.1.1-5,192.168.1.10-15"

# 根據(jù)逗號分隔不同的ip, 結(jié)果是一個(gè)列表[192.168.1.1-5, 192.168.1.10-15]
for ip in a.split(','):
    # ip就是遍歷剛才的列表取得值, 根據(jù).從右到左分割一次ip字符串, 獲取結(jié)果192.168.1和1-5, 分別存給兩個(gè)變量
    shuffix, _ = ip.rsplit('.', 1)
    # 用-切分1-5, 得出一個(gè)范圍區(qū)間
    start, end = map(int, _.split('-'))
    for num in range(start, end+1):
        # num為上述范圍區(qū)間的數(shù), 然后拼接一開始的字符串, 組成新ip
        print('{}.{}'.format(shuffix, num))
過去多啦不再A夢
# coding: utf-8

import os

str = '192.168.1.1-5,192.168.1.10-15'

for x in str.split(','):
    _, y = os.path.splitext(x)
    start, end = y.replace('.', '').split('-')
    for i in range(int(start), int(end) + 1):
        print '{}.{}'.format(_, i)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template