Commit 2257f5d60b2519540cab8a1a66d3ae68138a3b6c
1 parent
fbaa6535
添加身份证号生成方法
Showing
1 changed file
with
32 additions
and
0 deletions
commons/scripts/createIdNum.py
0 → 100644
1 | +#coding=utf-8 | ||
2 | + | ||
3 | +# @Time : 2021/5/26 11:19 | ||
4 | +# @Author : Ljq | ||
5 | +# @File : createIdNum.py | ||
6 | +# @Software: PyCharm | ||
7 | + | ||
8 | + | ||
9 | +""" | ||
10 | + 生成身份证号 | ||
11 | +""" | ||
12 | + | ||
13 | +import time | ||
14 | +import random | ||
15 | + | ||
16 | + | ||
17 | +def cIN(): | ||
18 | + """ | ||
19 | + 身份证号生成 | ||
20 | + :return: | ||
21 | + """ | ||
22 | + # 拼接备用身份证号 | ||
23 | + area,birthday,policeStationCode,sex = 110101,time.strftime("%Y%m%d", time.localtime()),random.randint(10,99),random.randint(0,9) | ||
24 | + idNum_str = f"{area}{birthday}{policeStationCode}{sex}" | ||
25 | + basecCode = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2] | ||
26 | + checkCode = ["1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"] | ||
27 | + num = 0 | ||
28 | + for i in range(17): | ||
29 | + num = num + basecCode[i] * int(idNum_str[i]) | ||
30 | + return f"{idNum_str}{checkCode[num % 11]}" | ||
31 | +# | ||
32 | +# print(cIN()) | ||
0 | \ No newline at end of file | 33 | \ No newline at end of file |