def id(self, state=False):
# ???????????
distcode = self.dist_code
id = distcode['code'] # 6????
id += str(randint(1930, 2017)) # ??????
da = date.today() + timedelta(days=randint(1, 366)) # ??????
id += da.strftime('%m%d') # ??????
id += str(randint(100, 999)) # ????
count = 0
weight = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2] # ???
checkcode = {'0': '1', '1': '0', '2': 'X', '3': '9', '4': '8', '5': '7', '6': '6', '7': '5', '8': '5', '9': '3',
'10': '2'} # ???????
for i in range(0, len(id)):
count = count + int(id[i]) * weight[i]
id += checkcode[str(count % 11)] # ???????
if state:
return {'state': distcode['state'], 'id': id}
else:
return id
评论列表
文章目录