为什么这段代码不执行?

-3 python python-2.7

找不到语法错误或编译错误.为什么这个程序不执行?如果没有编译错误,我无法理解为什么这个程序没有运行.在下面的代码中,逻辑上可能出现什么问题?我可以在此代码中添加哪些内容以使其运行和交互?

def main():
    print "Checking platform...\r\r\r"
    platform = systemdetails()

def systemdetails():
    print "Hello! Welcome to the auto-commander"
    print "Please enter the platform specific number to automate."
    platforminput = integer(input ("1. Cisco       2. Linux/Unix     3. Juniper       4. VMware vSphere/NSX \n:"))
    if platforminput ==1:
        platform='cisco_ios'
    elif platforminput ==2:
        platform='linux'
    elif platforminput ==3:
        platform='juniper'
    elif platforminput ==4:
        platform='vmware'
    else:
        print "Commander has to repeat the question...\n\n"
        systemdetails()
    return platform
Run Code Online (Sandbox Code Playgroud)

Rya*_*ing 5

你需要调用你的主要功能.一个仍然可以重现您的问题的最小例子是

def main():
    print "Hello World!"
Run Code Online (Sandbox Code Playgroud)

为了使这个工作,你需要打电话给你的主要

def main():
    print "Hello World!"

main()
Run Code Online (Sandbox Code Playgroud)

一般来说,main如果你没有被导入,你只想打电话给你,这可以这样做

def main():
    print "Hello World!"

if __name__ == '__main__':
    main()
Run Code Online (Sandbox Code Playgroud)