Back
How can I generate a string of size N.
I want it to be of uppercase English letters and numbers like this:
How can I do it in Python.
Just use random.sample , for instance look at this code:
import randomimport stringchar_set = string.ascii_uppercase + string.digitsprint ''.join(random.sample(char_set*5, 5))
import randomimport string
char_set = string.ascii_uppercase + string.digitsprint ''.join(random.sample(char_set*5, 5))
Use the below-mentioned code:-
import uuidlowercase_str = uuid.uuid4().hex
import uuid
lowercase_str = uuid.uuid4().hex
You can use the following video tutorials to clear all your doubts:-
31k questions
32.8k answers
501 comments
693 users