這裏定義是程序:如何函數獲取調用,而不在Python
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()
對不起,但你將不得不對你的問題更具體。 – SethMMorton
如果我刪除最後一行IndexSearchStrind()並運行程序,它會得到執行。 –
我的意思是,如果沒有定義函數,程序甚至會被執行。我是Python的新手。 –