#decoding =utf-8
‘‘‘
Write a table of employee information that can be queried by users!
1| user authentication
ID Name Department Phone
Query Keywords: name
‘‘‘
Import linecacheinput01=raw_input ("pls write your name:") I=1name=[]count = Len (open (' User.txt ', ' RU '). ReadLines ()) While i<=count:fline = Linecache.getline ("User.txt", i) Li=fline.split ("", 3) i+=1 Print li[1] Name.append (li[1]) print namefor x in Name:if x=input01:print "it ' s ok!" Break
Feel that the program is relatively dead and has some drawbacks:
1) Independent definition of a name list, wasting memory
2) If judgment, it is best to join the first while loop to get the name field
This article is from the "Emperor Heart Zen Shadow" blog, please be sure to keep this source http://yedee.blog.51cto.com/513852/1548926
L01-04:python Query Employee Information Sheet Practice