进程返回0 (0x0) python
我正在学习Python,想创建一个简单的菜单,让用户输入一个数字。运行脚本时,控制台出现了错误。有什么建议可以帮我解决这个问题吗?我是在Atom编辑器中编写的代码。在我添加menu()之前,代码是正常的,只是用了普通的print()语句。但我想以后添加更多的横幅之类的东西,觉得调用一个函数比到处都是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 个回答
1
你从来没有调用过mainMenu这个函数,所以你的代码几乎没有做什么,最后返回0(这意味着没有错误)。
你应该在你的代码里加一个对mainMenu函数的调用。
mainMenu()