# 生成随机字符串

Source: https://blog.ferstar.org/posts/generate-random-string-bash-python/






```python
import random
import string
def GenString(length):
    # return ''.join(random.sample(chars, 15))    # 得出的结果中字符不会有重复的
    return ''.join([random.choice(string.ascii_letters) for i in range(length)])
```

