In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
Today, I would like to share with you how python simulates the rules of generating loan card numbers. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
1. The generation rules are as follows:
The code of the loan card has a total of 16 digits, and the last two are check bits.
The rules for the entire loan card coding are as follows:
The first three are numbers or capital letters, respectively.
Fourth to 14th: numbers, respectively.
The check code for the last two digits is
The number obtained by multiplying the first fourteen digits by the weight, dividing the remainder by 97, and adding 1.
If this number is single digit, it needs to be preceded by a zero.
The corresponding weights of the first 14 bits of the code are 1, 3, 5, 7, 11, 11, 13, 1, 1, 17, 17, 19, 9, 7, 23, 29.
If a bit is a letter, you need to convert the letter to a number, A to 10, B to 11, and so on.
2. The python code is as follows:
Import randompower = [1, 3, 5, 7, 11, 2, 13, 1 # weight arr = [] sum = "randomly generate the first 14 digits and save them in the list arr (14): value = random.randint (0prime9) arr.append (value) # multiplied by weight plus for j in range (14): value = arr [j] * power [j] sum = sum + value# divided by 97 plus the remainder 1last_two = sum% 97 +" if the number is single digit You also need to add a zero if last_two > 10: shiwei = last_two / / 10 gewei = last_two% 10 arr.append (shiwei) arr.append (gewei) else: shiwei = 0 gewei = last_two arr.append (shiwei) arr.append (gewei) # output loan card number print ("loanCardNo:", end= ") for i in range (0Jue 16): print (ARR [I]] End= ") these are all the contents of the article" how python simulates the rules for generating loan card numbers " Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.