这是程序:
import sys
def IndexSearchString():
'''
This function search a string in a password file through index and gives the result.
:return: none
:return type: none
:author: Neeraj
'''
fieldindex = int(sys.argv[1])-1
stringsrch = sys.argv[2]
file_name = open("passwd", "r")
for store_file in file_name:
temp = store_file.split(":")
search = temp[fieldindex]
#print search
if stringsrch in search:
print store_file
#print sys.stdout.write(store_file)
return
#IndexSearchString()