歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Unix知識 >> 關於Unix

python的while Ture語句,那位大俠幫我看看


以下是我用python寫的安裝菜單,本人剛剛開始接觸python
1 #!/usr/bin/python
2 import os,sys,re,strings
3
4 while Ture:
5 print "=============================="
6 print "we will install V2-Program"
7 print "0 Return to Linux"
8 print "1 View parameter file"
9 print "2 Install Basic service"
10 print "3 Install Application service \n"
11
12 choice = raw_input("please input a number: ")
13 choice = int(choice)
14 if choice == 0:
15 pass
16 elif choice == 1:
17 os.system('vi a.py')
18 elif choice == 2:
19 while Ture:
20 print " Install Basic service "
21 print "================================================="
22 print "Make a Choice from the Menu below"
23 print "0 Return to main menu"
24 print "1 Install MySQL Database"
25 print "2 Install PostgreSQL Database"
26 print "3 Install Web Service"
27 choice = raw_input("please input a number: ")
28 choice = int(choice)
29 if choice == 0:
30 break
31 if choice == 1:
32 print "we will install mysql"
33 if choice == 2:
34 print "we will install postgresql"
35 if choice == 3:
36 print "we will install tomcat,apache,jdk...."
37 else:
38 continue
39 elif choice == 3:
40 while Ture:
41 print " Install Application service "
42 print " ================================================="
43 print "Make a Choice from the Menu below"
44 print "0 Return to main menu "
45 print "1 install i-TVsite service "
46 print "2 install i-Tvcenter service "
47 print "3 install i-Studio service "
48 print "4 install i-Streaming service"
49 print "5 install i-Gateway service"
50 choice = raw_input("please input a number: ")
51 choice = int(choice)
52
53 if choice == 0:
54 break
55 if choice == 1:
56 while Ture:
57 print "we will install i-TVsite service"
58 print "================================================="
59 print "Make a Choice from the Menu below"
60 print "0 Return to main menu"
61 print "1 install EPG service"
62 print "2 install CDN service"
63 print "3 install bdp_server service"
64 print "4 install Upgrade service"
65 choice = raw_input("please input a number: ")
66 choice = int(choice)
67 if choice == 0:
68 break
69 if choice == 1:
70 print "we will install EPG service"
71 if choice == 2:
72 print "we will install CDN service"
73 if choice == 3:
74 print "we will install bdp_server service"
75 if choice == 4:
76 print "we will install Upgrade service"
77 else:
78 continue
79 if choice == 2:
80 while Ture:
81 print "we will install i-Tvcenter service"
82 print " ================================================="
83 print "Make a Choice from the Menu below"
84 print "0 Return to main menu"
85 print "1 install oss service"
86 print "2 install ibusiness service"
87 print "3 install statistics service"
88 choice = raw_input("please input a number: ")
89 choice = int(choice)
90 if choice == 0:
91 break
92 if choice == 1:
93 print "we will install oss service"
94 if choice == 2:
95 print "we will install ibusiness service"
96 if choice == 3:
97 print "we will install statistics service"
98 else:
99 continue
100 if choice == 3:
101 print "we will install i-Studio service"
102 if choice == 4:
103 print "we will install i-Streaming service"
104 if choice == 5:
105 print "we will install i-Gateway service"
106 else:
107 print "Sorry, it is not a valid choice!"
108 else:
109 continue
我的while ture有沒錯誤。我運行的時候報錯了,錯誤為:
[root@test119 menu]# python kkk.py
File "kkk.py", line 29
if choice == 0:
^
SyntaxError: invalid syntax
Copyright © Linux教程網 All Rights Reserved