Skip to content

Instantly share code, notes, and snippets.

@tioover
Created September 14, 2012 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tioover/3722185 to your computer and use it in GitHub Desktop.
Save tioover/3722185 to your computer and use it in GitHub Desktop.
纪念
import random
def main():
#read data file.
try:
f = open("piaodata.txt", "r")
except IOError:
f = open("piaodata.txt", "w")
f.close()
f = open("piaodata.txt", "r")
body = f.read()
lines = body.split("\n")
# user input.
print("Please input your ID card number.")
idcardnum = raw_input()
if (not idcardnum.isdigit()) or (len(idcardnum) not in [18, 16]):
print "ID number error"
return
try:
lines.remove("")
except ValueError:
pass
number = []
flag = False
for line in lines:
if line == idcardnum:
flag = True
break
if len(line)<16:
number.append(int(line))
if flag:
print "Your ID number have been in list."
return
f = open("piaodata.txt", "a")
i=1
maxvol = 10
allnum = []
while i<=maxvol:
allnum.append(i)
i += 1
for numb in number:
if numb in allnum:
allnum.remove(numb)
try:
vol = random.randrange(1, len(allnum))
except ValueError:
print "Have been completed"
return
f.write("%s\n%d\n" % (idcardnum, allnum[vol]))
print("your number is: %d" % allnum[vol])
def main_loop():
main()
print "========"
print "only input <enter> the program will be exit, but inpnt any content then <enter> will be re-running this program."
if raw_input():
main_loop()
main_loop()
# Nyan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment