📜  在 python 代码示例中生成随机字符

📅  最后修改于: 2022-03-11 14:47:22.104000             🧑  作者: Mango

代码示例4
import random

#String
string = "abcdefghijklmnopqrstuvwxyz"
array = []
for c in string:
  array += [c]
 
print(array[random.randint(0, len(array)-1)])

# Faster and more efficient
random.choice(string)