titleList=[['a','b','c'],['1','2','3'],['x','y','z']]
word=[]
for i in range(10):
for t in titleList:
word.append(random.choice(t))
title=''.join(word)
print(title)
我希望组合出来的字符是随机的,为什么出来是一样的呢?
谢谢了,帮我找一下问题。
titleList=[['a','b','c'],['1','2','3'],['x','y','z']]
word=[]
for i in range(10):
for t in titleList:
word.append(random.choice(t))
title=''.join(word)
print(title)
我希望组合出来的字符是随机的,为什么出来是一样的呢?
谢谢了,帮我找一下问题。
2 回答5.1k 阅读✓ 已解决
2 回答1.1k 阅读✓ 已解决
4 回答979 阅读✓ 已解决
3 回答1.1k 阅读✓ 已解决
3 回答1.2k 阅读✓ 已解决
1 回答1.7k 阅读✓ 已解决
1 回答1.2k 阅读✓ 已解决
因为你的
word
数组变量是全局的,你应该修改为局部变量