py-basic/randomString.py

12 lines
261 B
Python
Raw Normal View History

2022-11-29 09:43:18 +01:00
import random
import string
def get_random_string(length):
# choose from all lowercase letter
letters = string.ascii_lowercase
result_str = ''.join(random.choice(letters) for i in range(length))
return result_str
print(get_random_string(20))