如何在Python3中的函数内导航函数

时间:2017-10-17 17:11:24

标签: python python-3.x

一旦你进入一个函数,你将如何在原始函数中从函数导航到函数? (我写了伪代码,因为我不知道如何完成这个)

def main():
    do...
    if something == 1
       access function(Success)
    elif something == 2
       access function(Failed)
    elif something == 3
       end script
    else
       print "choose a proper option idiot"
def menuSuc():
    print 1) How many total requests (Code _____)
    print 2) How many requests from _____ (IPs starting with 142.204)
    print 3) How many requests for isomaster-1.3.13.tar.bz2
    print q) Return to Main Menu
def menuFai():
    print 1) How many total failed requests (Codes _____)
    print 2) How many invalid requests for wp-login.php
    print 3) List the filenames for failed requests for files in /apng/assembler/data
    print q) Return to Main Menu

def success(argv):
    do.....    
    print menuSuc
    print information 
def failed(argv):
    do.....    
    print menuFai
    print information

1 个答案:

答案 0 :(得分:0)

只需在函数内调用要使用的函数即可。我会避免在Python代码中调用函数函数。别忘了在Python 3中打印是一个功能 - 添加"()"引号周围。

def main():
if something == 1:
   Success() # to access function(Success)
elif something == 2:
   Failed()
elif something == 3:
   return print("script Done")
else:
   print("choose a proper option") # no need to call people names :)

main()的