File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,9 @@ GitHub repository [One-Python-benchmark-per-day](https://github.com/rasbt/One-Py
9797
9898- convert 'tab-delimited' to 'comma-separated' CSV files [[ IPython nb] ( http://nbviewer.ipython.org/github/rasbt/python_reference/blob/master/useful_scripts/fix_tab_csv.ipynb?create=1 )]
9999
100+ - A random string generator [ function] ( ./useful_scripts/random_string_generator.py )
101+
102+
100103
101104<br >
102105
Original file line number Diff line number Diff line change 1+ import string
2+ import random
3+
4+ def rand_string (length ):
5+ """ Generates a random string of numbers, lower- and uppercase chars. """
6+ return '' .join (random .choice (
7+ string .ascii_lowercase + string .ascii_uppercase + string .digits )
8+ for i in range (length )
9+ )
10+
11+ if __name__ == '__main__' :
12+ print ("Example1:" , rand_string (length = 4 ))
13+ print ("Example2:" , rand_string (length = 8 ))
14+ print ("Example2:" , rand_string (length = 16 ))
15+
16+
17+ # Example1: 5bVL
18+ # Example2: oIIg37xl
19+ # Example2: 7IqDbrf506TatFO9
You can’t perform that action at this time.
0 commit comments