varma.nikhil22 at gmail.com
Mon Mar 26 08:50:44 CEST 2012
I want something to achieve like this :-
def random_number(id): # I am passing it from request
# do something
One input that is a number in return you are getting 6 digit alphanumeric
I tried this
s = '%06d' % random.randint(0, 999999)
it gives : '192862' (a string )
Thanks in advance.
On Mon, Mar 26, 2012 at 11:47 AM, Daniel da Silva <ddasilva at umd.edu> wrote:
> If you want it as an int:
> random.randint(100000, 999999)
> Or as a string:
> s = '%06d' % random.randint(0, 999999)
> On Mon, Mar 26, 2012 at 2:08 AM, Nikhil Verma <varma.nikhil22 at gmail.com>wrote:
>> Hi All
>> How can we generate a 6 digit random number from a given number ?
>> def number_generator(id):
>> When i am using this it is sometimes giving me five digit and sometimes 6
>> . I want to avoid encryption . Can i have alphanumeric 6 digit random
>> number from this .
>> Thanks in advance
>> Nikhil Verma
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list