This is a creation in Article, where the information may have evolved or changed.
The go language needs to write various function methods to achieve it. The code below represents the result of the individual writing the code in a very small amount of time and does not represent the optimal algorithm.
Func Main () {FMT. Println (' 0 ') fmt. Println (Randupstring (Ten)) fmt. Println (Randlowstring (Ten)) fmt. Println (Randintstring (5)) fmt. Println (RANDSTR (10))}//get random characters containing numbers, capitalization, etc., can be arbitrarily expanded. Func randstr (l int) string {var inibyte []byte var result bytes. Buffer for I: = 48; I < 123; i++ {switch {case I < 58:inibyte = Append (Inibyte, Byte (i)) case I >= && i < 91:inibyte = Append (Inibyte, Byte (i)) case I >= && i < 123:inibyte = Append (Iniby TE, Byte (i)}}} var temp byte for I: = 0; I < L; {if Inibyte[randint (0, Len (inibyte))]! = Temp {temp = inibyte[randint (0, Len (inibyte))] result. WriteByte (temp) i++}} return result. String ()}//Gets the uppercase random letter Func randupstring (l int) string {var result bytes. Buffer var temp byte for I: = 0; I < L; {if randint (+) = Temp {temp = Randint (+) result. WriteByte (temp) i++ }} return result. String ()}//Gets the lowercase random letter func randlowstring (l int) string {return strings. ToLower (Randupstring (L))}//Gets the number random number func randintstring (l int) string {var result bytes. Buffer var temp byte for I: = 0; I < L; {if Randint ()! = Temp {temp = Randint (.) WriteByte (temp) i++}} return result. String ()}func randint (min int, max int) byte {rand. Seed (time. Now (). Unixnano ()) return byte (min + rand). INTN (max-min))}
In Python, you can call the library file's own method, the key point is that the python generated characters are completely non-repeating, and the above go code to generate characters can only be adjacent to the non-repetition.
Import String,randomprint (". Join" (Random.sample (String.ascii_letters+string.digits))) #随机字符print (". Join ( Random.sample (String.ascii_letters)). Lower ()) #小写字母print (". Join (Random.sample (String.ascii_letters, 10)). Upper ()) #大写字母print (". Join (Random.sample (string.digits))) #数字