代码拉取完成,页面将自动刷新
同步操作将从 墨梅/createCard 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
from datetime import date
from datetime import timedelta
import json
import random
# 统一社会信用代码最后一位:代码字符集
check_dict = {
"0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9,
"A": 10, "B": 11, "C": 12, "D": 13, "E": 14, "F": 15, "G": 16, "H": 17, "J": 18, "K": 19, "L": 20, "M": 21,
"N": 22, "P": 23, "Q": 24, "R": 25, "T": 26, "U": 27, "W": 28, "X": 29, "Y": 30
}
dict_check = {value: key for key, value in check_dict.items()}
def random_name():
"""
随机姓名
:return:
"""
# 删减部分,比较大众化姓氏
# firstName = "赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻水云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳鲍史唐费岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅卞齐康伍余元卜顾孟平" \
# "黄和穆萧尹姚邵湛汪祁毛禹狄米贝明臧计成戴宋茅庞熊纪舒屈项祝董粱杜阮席季麻强贾路娄危江童颜郭梅盛林刁钟徐邱骆高夏蔡田胡凌霍万柯卢莫房缪干解应宗丁宣邓郁单杭洪包诸左石崔吉" \
# "龚程邢滑裴陆荣翁荀羊甄家封芮储靳邴松井富乌焦巴弓牧隗山谷车侯伊宁仇祖武符刘景詹束龙叶幸司韶黎乔苍双闻莘劳逄姬冉宰桂牛寿通边燕冀尚农温庄晏瞿茹习鱼容向古戈终居衡步都耿满弘国文东殴沃曾关红游盖益桓公晋楚闫"
# 百家姓全部姓氏
firstName = "赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卞齐康伍余元卜顾孟平" \
"黄和穆萧尹姚邵湛汪祁毛禹狄米贝明臧计伏成戴谈宋茅庞熊纪舒屈项祝董粱杜阮蓝闵席季麻强贾路娄危江童颜郭梅盛林刁钟徐邱骆高夏蔡田樊胡凌霍虞万支柯昝管卢莫经房裘缪干解应宗丁宣贲邓郁单杭洪包诸左石崔吉钮" \
"龚程嵇邢滑裴陆荣翁荀羊於惠甄麴家封芮羿储靳汲邴糜松井段富巫乌焦巴弓牧隗山谷车侯宓蓬全郗班仰秋仲伊宫宁仇栾暴甘钭厉戎祖武符刘景詹束龙叶幸司韶郜黎蓟薄印宿白怀蒲邰从鄂索咸籍赖卓蔺屠蒙池乔阴欎胥能苍" \
"双闻莘党翟谭贡劳逄姬申扶堵冉宰郦雍舄璩桑桂濮牛寿通边扈燕冀郏浦尚农温别庄晏柴瞿阎充慕连茹习宦艾鱼容向古易慎戈廖庾终暨居衡步都耿满弘匡国文寇广禄阙东殴殳沃利蔚越夔隆师巩厍聂晁勾敖融冷訾辛阚那简饶空" \
"曾毋沙乜养鞠须丰巢关蒯相查後荆红游竺权逯盖益桓公晋楚闫法汝鄢涂钦归海帅缑亢况后有琴梁丘左丘商牟佘佴伯赏南宫墨哈谯笪年爱阳佟言福百家姓终"
# 百家姓中双姓氏
firstName2 = "万俟司马上官欧阳夏侯诸葛闻人东方赫连皇甫尉迟公羊澹台公冶宗政濮阳淳于单于太叔申屠公孙仲孙轩辕令狐钟离宇文长孙慕容鲜于闾丘司徒司空亓官司寇仉督子颛孙端木巫马公西漆雕乐正壤驷公良拓跋夹谷宰父谷梁段干百里东郭南门呼延羊舌微生梁丘左丘东门西门南宫南宫"
# 女孩名字
girl = '秀娟英华慧巧美娜静淑惠珠翠雅芝玉萍红娥玲芬芳燕彩春菊兰凤洁梅琳素云莲真环雪荣爱妹霞香月莺媛艳瑞凡佳嘉琼勤珍贞莉桂娣叶璧璐娅琦晶妍茜秋珊莎锦黛青倩婷姣婉娴瑾颖露瑶怡婵雁蓓纨仪荷丹蓉眉君琴蕊薇菁梦岚苑婕馨瑗琰韵融园艺咏卿聪澜纯毓悦昭冰爽琬茗羽希宁欣飘育滢馥筠柔竹霭凝晓欢霄枫芸菲寒伊亚宜可姬舒影荔枝思丽'
# 男孩名字
boy = '伟刚勇毅俊峰强军平保东文辉力明永健世广志义兴良海山仁波宁贵福生龙元全国胜学祥才发武新利清飞彬富顺信子杰涛昌成康星光天达安岩中茂进林有坚和彪博诚先敬震振壮会思群豪心邦承乐绍功松善厚庆磊民友裕河哲江超浩亮政谦亨奇固之轮翰朗伯宏言若鸣朋斌梁栋维启克伦翔旭鹏泽晨辰士以建家致树炎德行时泰盛雄琛钧冠策腾楠榕风航弘'
# 名
name = '中笑贝凯歌易仁器义礼智信友上都卡被好无九加电金马钰玉忠孝'
# 10%的机遇生成双数姓氏
if random.choice(range(100)) > 10:
firstName_name = firstName[random.choice(range(len(firstName)))]
else:
i = random.choice(range(len(firstName2)))
firstName_name = firstName2[i:i + 2]
sex = random.choice(range(2))
name_1 = ""
is_male = True
# 生成并返回一个名字
if sex > 0:
girl_name = girl[random.choice(range(len(girl)))]
if random.choice(range(2)) > 0:
name_1 = name[random.choice(range(len(name)))]
is_male = False
name_1 = firstName_name + name_1 + girl_name
else:
boy_name = boy[random.choice(range(len(boy)))]
if random.choice(range(2)) > 0:
name_1 = name[random.choice(range(len(name)))]
name_1 = firstName_name + name_1 + boy_name
return {'name': name_1, 'sex': is_male}
# 随机生成手机号码
def random_phone():
"""
随机生成手机号
:return:
"""
prelist = ["130", "131", "132", "133", "134", "135", "136", "137", "138", "139", "147", "150", "151", "152", "153",
"155", "156", "157", "158", "159", "186", "187", "188", "199"]
return random.choice(prelist) + "".join(random.choice("0123456789") for i in range(8))
def create_idcard():
"""随机身份证号"""
codelist = getdistrictcode()
id = codelist[random.randint(0, len(codelist))] # 地区项
id = id + str(random.randint(1950, 1998)) # 年份项
da = date.today() + timedelta(days=random.randint(1, 366)) # 月份和日期项
id = id + da.strftime('%m%d')
id = id + str(random.randint(100, 300)) # 顺序号简单处理
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 = id + checkcode[str(count % 11)] # 算出校验码
return id
def getdistrictcode():
"""读取地区码"""
codelist = []
# 读取地区码
file = open('data/districtcode.txt',
encoding='GBK')
lines = file.readlines()
# 逐行读取
for line in lines:
# 如果每行中去重后不为空,并且6位数字中最后两位不为00,则添加到列表里。(最后两位为00时为省份或地级市代码)
if line.lstrip().rstrip().strip() != '' and (line.lstrip().rstrip().strip())[:6][-2:] != '00':
codelist.append(line[:6])
return codelist
def create_bank_account():
"""随机银行卡号"""
bankToBin = json.load(open("data/banknametobin.json", encoding="utf-8"))
tempBank = random.sample(bankToBin.keys(), 1)[0]
binNum = bankToBin[tempBank]
tempMidnum = ""
for x in range(9):
tempMidnum = tempMidnum + str(random.randint(0, 10))
bankNumNoLastcode = binNum + tempMidnum
sum = 0
for i in bankNumNoLastcode[-1::-2]:
for m in str(int(i) * 2):
sum = sum + int(m)
for j in bankNumNoLastcode[-2::-2]:
sum = sum + int(j)
if sum % 10 == 0:
lastCode = "0"
else:
lastCode = str(10 - sum % 10)
return {'number': bankNumNoLastcode + lastCode, 'bank': tempBank}
# 组织机构代码 9位
def create_organization():
weight_code = [3, 7, 9, 10, 5, 8, 4, 2] # Wi 代表第i位上的加权因子=pow(3,i-1)%31
org_code = [] # 组织机构代码列表
sum = 0
for i in range(8):
org_code.append(dict_check[random.randint(0, 30)]) # 前八位本体代码:0~9 + A~Z 31个
sum = sum + check_dict[org_code[i]] * weight_code[i]
C9 = 11 - sum % 11 # 代表校验码:11-MOD(∑Ci(i=1→8)×Wi,11)-->前8位加权后与11取余,然后用11减
if C9 == 10:
last_code = 'X'
elif C9 == 11:
last_code = '0'
else:
last_code = str(C9)
code = ''.join(org_code) + '-' + last_code # 组织机构代码
return code
# 统一社会信用代码 18位
def create_social_credit():
manage_code = [9] # 登记管理部门代码:9-工商
type_code = [1,2,3,9] # 9-1-企业,9-2-个体工商户,9-3-农民专业合作社,9-9-其他
area_code = '100000' # 登记管理机关行政区划码:100000-国家用
org_code = create_organization().replace('-','') # 组织机构代码
sum = 0
weight_code = [1, 3, 9, 27, 19, 26, 16, 17,20,29,25,13,8,24,10,30,28] # Wi 代表第i位上的加权因子=pow(3,i-1)%31
code = str(random.choice(manage_code)) + str(random.choice(type_code)) + area_code + org_code
for i in range(17):
sum = sum + check_dict[code[i:i+1]]*weight_code[i]
C18 = dict_check[31-sum % 31]
social_code = code + C18
print(social_code)
return social_code
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。