歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Unix知識 >> 關於Unix >> 用python在linux下編寫程序菜單,如何返回到上一層菜單!

用python在linux下編寫程序菜單,如何返回到上一層菜單!

日期:2017/2/28 11:07:04   编辑:關於Unix


#!/usr/bin/python
import os,sys,re,strings
print "=============================="
print "we will install V2-Program"
print "0 Return to Linux"
print "1 View parameter file"
print "2 Install Basic service"
print "3 Install Application service \n"
choice = raw_input("please input a number: ")
choice = int(choice)
if choice == 0:
pass
elif choice == 1:
os.system('vi a.py')
elif choice == 2:
print " Install Basic service "
print "================================================="
print "Make a Choice from the Menu below"
print "0 Return to main menu"
print "1 Install MySQL Database"
print "2 Install PostgreSQL Database"
print "3 Install Web Service"
choice = raw_input("please input a number: ")
choice = int(choice)
if choice == 0:
pass
if choice == 1:
print "we will install mysql"
if choice == 2:
print "we will install postgresql"
if choice == 3:
print "we will install tomcat,apache,jdk...."
elif choice == 3:
print " Install Application service "
print " ================================================="
print "Make a Choice from the Menu below"
print "0 Return to main menu "
print "1 install i-TVsite service "
print "2 install i-Tvcenter service "
print "3 install i-Studio service "
print "4 install i-Streaming service"
print "5 install i-Gateway service"
choice = raw_input("please input a number: ")
choice = int(choice)
if choice == 0:
pass
if choice == 1:
print "we will install i-TVsite service"
print " ================================================="
print "Make a Choice from the Menu below"
print "0 Return to main menu"
print "1 install EPG service"
print "2 install CDN service"
print "3 install bdp_server service"
print "4 install Upgrade service"
choice = raw_input("please input a number: ")
choice = int(choice)
if choice == 0:
pass
if choice == 1:
print "we will install EPG service"
if choice == 2:
print "we will install CDN service"
if choice == 3:
print "we will install bdp_server service"
if choice == 4:
print "we will install Upgrade service"
if choice == 2:
print "we will install i-Tvcenter service"
print " ================================================="
print "Make a Choice from the Menu below"
print "0 Return to main menu"
print "1 install oss service"
print "2 install ibusiness service"
print "3 install statistics service"
choice = raw_input("please input a number: ")
choice = int(choice)
if choice == 0:
pass
if choice == 1:
print "we will install oss service"
if choice == 2:
print "we will install ibusiness service"
if choice == 3:
print "we will install statistics service"
if choice == 3:
print "we will install i-Studio service"
if choice == 4:
print "we will install i-Streaming service"
if choice == 5:
print "we will install i-Gateway service"
else:
print "Sorry, 4 is not a valid choice!"
我如果想返回到上一層菜單
if choice == 0:
pass 直接就退出來了,有沒什麼辦法不讓他退出,讓它返回到上一層菜單!
Copyright © Linux教程網 All Rights Reserved