With Python3, you don’t need to consider coding issues. When making verification codes, it is better to create a list of commonly used words and then randomly select a few from it.
If you want to make a verification code, it is not recommended to generate it casually, because there is a high possibility that the generated character will be a rare character. It is recommended that you find a dictionary of commonly used Chinese characters and select it randomly
With Python3, you don’t need to consider coding issues.
When making verification codes, it is better to create a list of commonly used words and then randomly select a few from it.
The above is an example code for Python to randomly generate Chinese verification codes, you can refer to it.
If you want to make a verification code, it is not recommended to generate it casually, because there is a high possibility that the generated character will be a rare character. It is recommended that you find a dictionary of commonly used Chinese characters and select it randomly
Solution ideas
List of commonly used Chinese characters
Randomly take out the corresponding number of words
The following are the national standard first-level Chinese characters (3755, sorted by pinyin):
Code implementation
Output results
Select a random integer from 0x4e00 to 0x9fa5 and pass it to
unichr
.Randomly select 2 of all Chinese characters, there will indeed be many rare characters, for reference only: