进程返回0(0x0)python

时间:2020-05-18 22:37:51

标签: python python-3.x process scripting

我正在学习Python,我想通过输入数字来创建一个简单的菜单。 当我运行脚本时,控制台会给我这个错误。有关如何解决此问题的任何提示? 我正在用原子编码。它在我添加menu()并将其作为普通的print()语句之前运行。但是我想添加更多的标题和内容,只是认为在代码中调用函数比在各处都具有打印语句更漂亮。

Process returned 0 (0x0)        execution time : 0.060 s Press any key to continue . . .

这是我的代码=)

#!/usr/bin/env python

# Imports
import os
from time import sleep


#Definitions


def menu():
    print('''{0}

    _________________________________________________________________________________
                                {1}
                                    |    [MAIN MENUE]       |
                                    |    [1] Option 1       |
                                    |    [2] Option 2       |
                                    |    [3] Option 3       |
                                    |    [4] Option 4       | {0}
    _________________________________________________________________________________

    '''.format(PURPLE, BLUE))


clear = lambda: os.system('cls') #on Windows System

PURPLE = '\033[95m'
BLUE = '\033[94m'
GREEN = '\033[92m'
OCRA = '\033[93m'
RED = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'


#Start of Menu
def mainMenu():

    while True:
        try:

            menu()

            selection = input('{0}[>]Please input your module of choice:  '.format(BLUE))


            if selection == '1':
                print("{0}[+] You have chosen module 1".format(PURPLE))
                sleep(1.5)


            elif selection == '2':
                print("{0}[+] You have chosen module 2".format(PURPLE))
                sleep(1.5)


            elif selection == '3':
                print("{0}[+] You have chosen module 3".format(PURPLE))
                sleep(1.5)


            elif selection == '4':
                print("{0}[+] You have chosen module 4".format(PURPLE))
                sleep(1.5)


            else:
                print("{0}[-] Whoopsie, this module does not exist, try another".format(RED))
                sleep(1.5)
                clear()
                mainMenu()
        except ValueError:




                os.system("pause")

1 个答案:

答案 0 :(得分:1)

您永远不会调用mainMenu,因此您的代码几乎什么都不做,并返回0(表示没有错误)。

您应该在代码中添加对mainMenu函数的调用

mainMenu()