import random
my_list = ['nu', 'ne', 'na', 'ku', 'ke', 'ka']
for i in xrange(0,50):
tmp_string = ''
count = random.randrange(1,4) # choose a random between 1 and 4
for j in xrange(0, count):
# add a random member of the list to the temporary string
tmp_string = tmp_string + random.choice(my_list)
print tmp_string # print each final string
import random
input = [...] # Your input strings
output = ''
random.seed() # Seed the random generator
for i in range(0,len(input)):
N = 1+random.randrange(4) # Choose a random number between 1 and 4
for j in range(0,N): # Choose N random items out of the input
index = random.randrange(len(input)-j)
temp = input[index]
input[index] = input[len(input)-j-1]
input[len(input)-j-1] = temp
output += temp
output += ' '
print output
尝试使用以下Python代码:
在Python中:
在C:
^{pr2}$相关问题 更多 >
编程相关推荐