def main() :
for i in range(10) :
print(randomCharacter("abcdef", end="")
print()
def randomCharacter(characters) :
n = len(characters) :
r = randint(0, n - 1)
return characters[r]
main()
我正在尝试生成随机字符
答案 0 :(得分:0)
打印(randomCharacter(" abcdef",end ="")这里你错过了一个括号")"
print(randomCharacter("abcdef", end=""))
在python 3.6中
import random as rnd
def main() :
for i in range(10):
print(randomCharacter("abcdefg"))
print()
def randomCharacter(characters):
n = len(characters)
r = rnd.randrange(0, n - 1)
return characters[r]
main()