标签:
import re import datetime import os import sys str1 = ‘350825198808080808‘ pat = re.search(r‘[1-9][0-9]{5}([0-9]{4})([0-9]{2})([0-9]{2})[0-9]{3}[0-9X]‘, str1) if len(str1) != 18 or not pat: print "inValid" sys.exit(1) try: datetime.date(int(pat.group(1)),int(pat.group(2)),int(pat.group(3))) except ValueError,e: print e sys.exit(1) except: sys.exit(1) print "Valid"
标签:
原文地址:http://www.cnblogs.com/linyfeng/p/5965932.html