Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def randomString(length):
- lower = 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z'.split(',')
- caps = 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z'.split(',')
- numbers = '0,1,2,3,4,5,6,7,8,9'.split(',')
- special = '!,@,#,$,%,^,&,*,(,),-,_,~,=,+'.split(',')
- try:
- float(length)
- except ValueError:
- length = 32
- x = array_merge(array_merge(numbers, special), array_merge(lower, caps))
- random.shuffle(x)
- str = ''
- for ind in range(0, length):
- str += x[ random.choice(range(len(x))) ]
- return str
- def array_merge(first_array, second_array):
- if isinstance(first_array, list) and isinstance(second_array, list):
- return first_array + second_array
- elif isinstance(first_array, dict) and isinstance(second_array, dict):
- return dict(list(first_array.items()) + list(second_array.items()))
- elif isinstance(first_array , set) and isinstance(second_array , set):
- return first_array.union(second_array)
- return False
- length = 30
- String = randomString(length)
- print(String)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement