如何在Python3的函数中浏览函数

2024-10-04 11:28:35 发布

您现在位置:Python中文网/ 问答频道 /正文

一旦你在一个函数中,你将如何在原来的函数中从一个函数导航到另一个函数(我编写了伪代码,因为我不知道如何实现这一点)

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

Tags: 函数foraccessdeffunctionrequestsdosomething
1条回答
网友
1楼 · 发布于 2024-10-04 11:28:35

只需在函数内部调用要使用的函数。我会避免在Python代码中调用函数。别忘了在Python3中print是一个函数,在引号周围加“()”

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 :)

主()

相关问题 更多 >