简体   繁体   中英

python : TypeError: () takes exactly 1 argument (0 given)

def Check_InActive(Policy_Name):   
 with open ('Inactive_Policy_list.txt','r+') as p:  
  for word in p:  
   if (Policy_Name == word):  
    print (Policy_Name,word)  
    return "Inactive"  
  else:  
   return "Active"

Policy = raw_input("Enter Policy Name: ")  
Check_InActive(Policy)  
Flag = Check_InActive()  
if (Flag in "Inactive"):  
 print(Policy,"is ",Flag)  

Can someone help me below error.

##    Flag = Check_InActive()
## TypeError: Check_InActive() takes exactly 1 argument (0 given)

You should provide an argument to the function, and you don't need this call Check_InActive(Policy) , because you don't store the result

Policy = raw_input("Enter Policy Name: ")  
Check_InActive(Policy)  
Flag = Check_InActive(Policy)  
if (Flag in "Inactive"):  
    print(Policy,"is ",Flag) 

You need to pass the argument to the Check_InActive functin. You should call it this way:

Policy = raw_input("Enter Policy Name: ")    
Flag = Check_InActive(Policy)  
if (Flag in "Inactive"):
    print(Policy,"is ",Flag)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM