def get_random_url_safe_string(self, length):
"""
Returns a random url-safe string of specified length, where
0 < length <= 256. The returned string will always start with
an alphabetic character.
"""
if length <= 0:
length = 1
elif length > 256:
length = 256
random_string = ''
while length > 0:
random_string += random.choice(string.lowercase)
length -= 1
return random_string
评论列表
文章目录