我的程序返回时“解析时意外的EOF”或“预期的缩进块”都是语法错误

时间:2015-05-14 00:13:27

标签: python debugging python-3.x syntax-error unexpectendoffile

这是一个我一直在研究的小型终端式程序,但由于代码问题而停止了。(用Python 3.4.1编写)任何人都可以帮忙吗?

import time
import sys
import os
#This next part restarts the program in case of invalid user/pass combination
def restart_program():
    python = sys.executable
    os.execl(python, python, * sys.argv)
#definitions of strings in lists
h = 'h'
d = 'd'
ma = 'ma'
me = 'me'
c = 'c'
a = 'a'
l = 'l'
yes = 'yes'
no = 'no'
y = 'yes'
n = 'no'
Yes = 'yes'
No = 'no'
YEs = 'yes'
NO = 'no'
YES = 'yes'
nO = 'no'
yES = 'yes'
yeS = 'yes'
yEs = 'yes'
YeS = 'yes'
#String lists
varList1 = [d,ma,me,c,a,l,h]    
yeS = [yes,y,Yes,YEs,YES,yES,yeS,yEs,YeS]
nO = [no,n,No,NO,nO]
admin = 'admin'
deerfield = 'deerfield'
password = 'password'
cmenasco = 'cmenasco'
cyape = 'cyape'
guest = 'guest'
userList = [cmenasco,cyape,guest]
passList = [admin,deerfield,password]

print('Booting up.....')
print('...............')
print('...............')
print('')
print('')
print('-----LOGIN-----')
TempUser = input('username: ')
TempPassword = input('password: ')

if TempUser == cmenasco:
    if TempPassword == admin:
        print('welcome-Christian-')
        print('------------------')
        time.sleep(2.5)
        print('*-------------------------------------------*')
        print('|         Welcome to SAMNET v1.0!           |')
        print('|       (type in a catagory to view)        |')
        print('|              -documents(d)-|              |')
        print('|                  -mail(ma)-|              |') 
        print('|              -messages(me)-|              |')
        print('|             -classified(c)-|              |')
        print('|            -accountinfo(a)-|              |')
        print('|                 -logout(l)-|              |')
        print('|                   -help(h)-|              |')
        print('|                                           |')
        print('|               c.2013                      |')
        print('*-------------------------------------------*')
        var1 = input('press any key to continue: ')
#Documents
        if var1 == d:
            print('*------------------------------------------*')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('*------------------------------------------*')


#Mail
        elif var1 == ma:
            print('*------------------------------------------*')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('*------------------------------------------*')



#Messages
        elif var1 == me:
            print('*------------------------------------------*')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('*------------------------------------------*')



#Classified
        elif var1 == c:
            print('*------------------------------------------*')
            print('|                                          |')
            print('| 1. report22.txt                          |')
            print('| 2. introd.txt                            |')      
            print('| 3. mason.txt                             |')
            print('| 4. recent_inves.txt                      |')      
            print('| 5. information/about.txt                 |')
            print('| 6. recent_events(rus_com)                |')
            print('| 7. support                               |')
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('*------------------------------------------*')


#Account Info
        elif var1 == a:
            print('*------------------------------------------*')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('*------------------------------------------*')


#Help


        elif var1 == h:     
            print('*------------------------------------------*')
            print('|                help                      |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('*------------------------------------------*')






#Logout
        elif var1 == l:
            print('*------------------------------------------*')
            print('|       SAMNET-path/user-cmenasco          |')
            print('|                                          |')
            print('|         Do you want to logout?           |')
            print('|                                          |')
            print('|                                          |')
            print('|******************************************|')
            print('|               Warning!                   |')
            print('|If you logout, session will be terminated!|')
            print('|******************************************|')
            print('|                                          |')
            print('|                                          |')
            print('*------------------------------------------*')
            respondYN = input('(yes/no) ')
            if respondYN == yeS:
                restart_program()
            elif respondYN == nO:






            #make the pages for each link

      #  elif var1 

这就是问题 - 它说有一些“预期的缩进”或“解析时出现意外的EOF” - 这是未完成的程序的其余部分 -

elif TempUser == cyape
    if TempPassword == deerfield
        print('success')

if TempUser == guest:
    if TempPassword == password:
        print('success')

if TempUser is not userList or TempPassword is not passList:
    print('incorrect password/username combination')

if TempUser is not userList or TempPassword is not passList:
        restart_program()

1 个答案:

答案 0 :(得分:1)

elif,如果缺少冒号

elif TempUser == cyape:
    if TempPassword == deerfield:
        print('success')