def is_string_ipv4(string):
    """
    判断一个字符串是否符合ipv4地址规则

    :param string:  输入的字符串
    :return: 一个元祖: (逻辑结果, ipv4 string 或 None)
    """
    string = string.strip()
    seg = string.split('.')
    if len(seg) != 4:
        return False, None
    else:
        try:
            if not all([_si.isdigit() and -1 < int(_si) < 256
                        for _si in seg]):
                return False, None
            return True, string
        except ValueError:
            return False, None