forked from VenkateshDoijode/selenium_with_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomString.py
More file actions
29 lines (20 loc) · 868 Bytes
/
RandomString.py
File metadata and controls
29 lines (20 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'''
Created on 01-Jul-2020
@author: venkateshwara D
'''
import string
import random
'''The random.choices() method returns a list with the randomly selected element from the specified sequence.
You can weigh the possibility of each result with the weights parameter or the cum_weights parameter.
The sequence can be a string, a range, a list, a tuple or any other kind of sequence.
Syntax
random.choices(sequence, weights=None, cum_weights=None, k=1)'''
def random_AlphaPrefix(N):
res = ''.join(random.choices(string.ascii_uppercase + string.digits, k = N))
return res
def random_Characters(N):
res = ''.join(random.choices(string.ascii_letters, k = N))
return res
# print result
print("The generated random alpha string : " + random_AlphaPrefix(8))
print("The generated random string : " + random_Characters(8))