The method of randomly generating Chinese characters in Golang and python. .

The code is very concise, everyone can understand, not much to say.

GO language:

func main() {

   a:=make([]rune,100)
   for i:=range a {
	a[i]=rune( RandInt(19968,40869))
 }
  fmt.Println(string( a))
}
func RandInt(min, max int64) int64 {
    rand.Seed(time.Now().UnixNano())
    return min + rand.Int63n(max-min)
}

 

More concise in python

import random, string
def GB2312():
    head = random.randint(0x4E00, 0x9FA5)
    return head
s=''
for i in range(1000):
    s=s+chr(GB2312())
print(s)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325446433&siteId=291194637