📜  验证信用卡号码 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:22.039000             🧑  作者: Mango

代码示例1
python
import re

def check(card):
    if not re.search("^[456]\d{3}(-?\d{4}){3}$",card) or re.search(r"(\d)\1{3}", re.sub("-", "",card)):
        return False
    return True

for i in range(int(input())):
    print("Valid" if check(input()) else "Invalid")