Skip to content

Instantly share code, notes, and snippets.

@shiweifu
Created August 31, 2012 10:04
Show Gist options
  • Save shiweifu/3551067 to your computer and use it in GitHub Desktop.
Save shiweifu/3551067 to your computer and use it in GitHub Desktop.
random generator a string
def randstr(l):
s = ["chr(randint(65, 90))", #A-Z
"chr(randint(97, 122))", #a-z
"str(randint(0,9))"] #0-9
return "".join([eval(s[randint(0, len(s)-1)]) for x in xrange(l)])
@shiweifu
Copy link
Author

其实可以弄成一行版的,但会浪费内存

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment