#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#python2.7
import string,random
def get_clice(num):
res =[]
tmp = list(string.lowercase)
for i in range(num):
res.append(''.join(random.sample(tmp,random.randint(3,7))))
return res
print get_clice(20)
追问能用python3.6写个吗
追答#!/usr/bin/python
# -*- coding: utf-8 -*-
#python3.x
import string,random
def get_clice(num):
res =[]
tmp=string.ascii_letters #py3 这个函数把大小写都包括进去了
for i in range(num):
res.append(''.join(random.sample(tmp,random.randint(3,7))))
return res
print(get_clice(20))