#-coding:utf-8-
def chartonum(c):
return ord(c)-ord('0')
def getdigitsum(num):
s=0
while num>0:
s+=num%10
num//=10
return s
def isvalid(cardno):
if not cardnoisdigit() or len(cardno)!=8:return False
l=[chartonum(c) for c in cardno]
result=l[7]+l[5]+l[3]+l[1]
for i in [0,2,4,6]:
result+=getdigitsum(l[i]2)
return False if result%10 else True
if __name__=="__main__":
import sys
if sysversion[0]=='3':raw_input=input
valid=isvalid(cardno)
if valid:
print("你输入的卡号合法")
else:
print("你输入不是合法卡号")
欢迎分享,转载请注明来源:浪漫分享网
评论列表(0条)