首页 技术 正文
技术 2022年11月13日
0 收藏 369 点赞 4,832 浏览 1117 个字

使用Python改写的身份证信息查询小程序

花了几天时间过了一遍python基础。真心感觉python让世界充满了爱…
先简单的使用一下python好了,拿以前写的《C语言身份证信息查询系统(修改版)》开刀~

很多东西,不需要考虑C语言的细节问题了,很多封装好的功能。方便好多。代码也自然少了好多。

python的‘泡菜’功能也是相当的棒!

import picklepickle_file = open('cityid_data.pkl', 'rb')
city = pickle.load(pickle_file)str = input('请输入身份证号码:')
cid = str[:6]
birth = str[6:14]
cname = city[cid]num = int(str[1])
tmpsum = int(str[0])*7 + int(str[1])*9 + int(str[2])*10 + int(str[3])*5 + int(str[4])*8 \
+ int(str[5])*4 + int(str[6])*2 + int(str[7])*1 + int(str[8])*6 + int(str[9])*3 \
+ int(str[10])*7 + int(str[11])*9 + int(str[12])*10 + int(str[13])*5 \
+ int(str[14])*8 + int(str[15])*4 + int(str[16])*2;remainder = tmpsum % 11sex = int(str[16]) % 2
if sex == 1:
sex = '男'
else :
sex = '女'maptable = {0: '1', 1: '0', 2: 'x', 3: '9', 4: '8', 5: '7', 6: '6', 7: '5', 8: '4', 9: '3', 10: '2'}
if maptable[remainder] == str[17]:
print('<身份证合法>')
print('性别:' + sex)
print('出生日期:' + birth)
print('归属地:' + cname)
else :
print('<身份证不合法>')

百度网盘真是太讨厌了,链接总是失效。
直接上传到百度文库好了。。。

地址:http://wenku.baidu.com/view/4be42951eff9aef8951e062f.html

生成’泡菜’方法:

city = {'110000':'北京市',
'110100':'北京市市辖区',
...
}
import pickle
pickle_file = open('cityid_data.pkl', 'wb')
pickle.dump(city, pickle_file)
pickle_file.close()

之后,把生成的cityid_data.pkl和上面的python程序放在一起运行就妥妥的了。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,111
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,584
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,431
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,203
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,838
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,922