Hello, everyone! Good morning. Today is a happy weekend. Today, we share 1 interesting projects. We use Python to make the national ID number verification and inquiry system. The finished product interface is as follows:
This system can verify the ID number, age, gender and certification. It looks like it is not very tall. Actually, it is not very complicated. It involves Python string processing, table reading and writing and Gui production. It is suitable for friends who have a certain Python basis.
The ID number is usually composed of 18 digit numbers, the first 6 are address codes, seventh to 14 are birth date codes, fifteenth to 17 bits are order codes, and eighteenth are parity codes. The 6-digit address code is the administrative division code of the county (city, district) where the registered permanent residence of the coding object is located; The 8-digit date of birth code is the date of birth; The 3-digit sequence code is the distribution code of the police station under the jurisdiction of the county (city, district). The odd number of the sequence code is allocated to men and the even number to women; The 1-digit check code is calculated according to the unified formula.
This is a common online search. 1 random ID number will return to the county address. We have to find all the corresponding relationships. It happens that there are already ready-made online, but we need to sort out them. We can go online to find them. But we need to polish our eyes. There is a version that is wrong. I can’t find it.
The last check code algorithm of ID card is as follows:
1. The first 17 digits of ID number are multiplied by different coefficients, and the coefficients from first to seventeenth are 79105842163 79105842 respectively.
② Add the 17 products obtained.
③ Divide the added sum by 11 and get the remainder.
④ The last 8 digits of the verification code 7 may correspond to 1. The last 8 digits of the verification code 7 may be 2. The last 8 digits of the verification code 7 are 3. The remaining 8 digits of the verification code 7 may be 2.
The code implementation is as follows:
The first step of rule reference is two lines of Python code
It has to be said that Python is simple and convenient
The rules also refer to the first step, and the code is as follows:
So far, the main function of the project has been realized. Now we need to find a way to realize it with GUI interface.
This step is mainly implemented with pyqt5. I’ll post the core code below:
Firstly, the label and text box are laid out in grid mode, and the text box is decorated with setstylesheet
Then set the query button and layout, and then bind it with the check function (signal)
Then, display the query results in the text box in the check function
Finally, set the picture background of the main window
So far, the project has been completed. Have you learned it?
However, to declare that the query functions introduced in this article are all forward queries, that is, the principle of analysis is derived from the network without the 100% accuracy and the personal ID number can not be calculated in the premise of the known ID number.
The code and form that this article has uploaded is available in the background of official account [python’s crawler and data analysis. “20200329” is obtained.
This work adoptsCC agreement, reprint must indicate the author and the link to this article