In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces python how to achieve Mini Program automatic generation of test data related knowledge, the content is detailed and easy to understand, simple and fast operation, has a certain reference value, I believe that after reading this python how to achieve Mini Program automatic generation of test data article will have a harvest, let's take a look.
Method 1:
Def get_validate_checkout (id17):
"" get the check code algorithm ""
"" 17-digit digital ontology code weight ""
Weight = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4,2]
"mod11, corresponding to the check code character value"
Validate = ['1mm,' 0mm, 'Xbox,' 9stories, '8bands,' 7bands, '6bands,' 5bands, '4bands,' 3bands,'2']
Sum = 0
For i in range (0, len (id17)):
Sum = sum + int (id17 [I]) * weight [I]
Mode = sum 11
Return validate [mode]
Method 2:
Def get_random_idnumber ():
"" generate a randomly available ID number, sex = 1 for male, sex = 0 for female ""
"address code generation"
Id_number = "110108"
"" Birthday starts and ends ""
Start, end = "1960-01-01", "1999-12-30"
Days = (datetime.datetime.strptime (end, "% Y-%m-%d")-datetime.datetime.strptime (start, "% Y-%m-%d") .days + 1
Birth_days = datetime.datetime.strftime (datetime.datetime.strptime (start, "% Y-%m-%d") + datetime.timedelta
(random.randint (0, days)), "% Y%m%d")
Id_number = id_number + str (birth_days)
"" sequence code ""
For i in range (2):
"the last value can include"
N = random.randint (0,9)
Id_number = id_number + str (n)
"" Sex Code ""
Sex_id = random.randint (1,2)
Id_number = id_number + str (sex_id)
"" check code ""
Check_out = get_validate_checkout (id_number)
Id_number = id_number + str (check_out)
Return id_number
The penultimate line in method 2 invokes the method already defined in method 1: the get_validate_checkout,get_validate_checkout method is mainly to obtain the algorithm of the check code, and the second method is the Mini Program that really generates the ID card number test data.
To execute the Mini Program, you need to import the appropriate module first, for example:
Import datetime
Import random
3. The rules for generating ID card numbers are: address code, sequence code, gender code and check code. If you meet the above four conditions, you can generate the ID card number test data that we need to use, and you no longer need Baidu to search. Execute one time to generate the test data you want. Because the result of Mini Program's execution is returned as return, to see the generated ID number, you need to define a variable to receive or modify the return to print, and print it directly to the console output.
This is the end of the article on "how to automatically generate test data for Mini Program by python". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to achieve Mini Program automatic test data generation by python". If you want to learn more knowledge, you are welcome to follow 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.