File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ VTGwsgMjVt4rXtS
2+ VcBNNj2wxpxzfIn
3+ tRkSWNZvlKtGZ9t
4+ GGfymamjpwD69rx
5+ vMGIGYdAPwIG5zT
6+ Mt60KsjdS6AdM4z
7+ SsTkjAOskJCH1SJ
8+ pG9w6OXJyNGNgu2
9+ er4a3ZxEg1XuX0g
10+ lIe85Mgl7Dg9aIh
Original file line number Diff line number Diff line change 1+ # -*- coding: utf-8 -*-
2+ """
3+ Created on Mon May 11 16:04:59 2015
4+
5+ @author: partrita
6+ """
7+
8+ from random import Random
9+
10+ def codeGenerator (number , codeLength = 15 ):
11+ print '**** Code Generator ****'
12+ codeFile = open ('codes.txt' , 'w' )
13+ if number <= 0 :
14+ return 'invalid number of codes'
15+ else :
16+ chars = 'abcdefghijklmnopgrstuvwxyzABCDEFGHIJKLMNOPGRSTUVWXYZ1234567890'
17+ random = Random ()
18+ for j in range (1 , number + 1 ):
19+ str = ''
20+ for i in range (1 , codeLength + 1 ):
21+ index = random .randint (1 , len (chars ))
22+ str = str + chars [index - 1 ]
23+ codeFile .write (str + '\n ' )
24+
25+ print codeGenerator (10 )
You can’t perform that action at this time.
0 commit comments