意外的身分

时间:2019-02-19 21:25:34

标签: python function if-statement

我正在尝试运行该功能并将在此功能中收集的数据发送到另一个适当的功能。在TypeOfEncrypt == 1:

处出现缩进错误
def main():

        FileToRead =  input("Select the File in Directory :")


        File = open("C:\\Users\\User\\Documents\\" + FileToRead + ".txt", 'r')

        Data = File.read()

        File.close()

        print (Data)

        if Data != None :
            TypeOfCipher = int(input("For Encrypt Press 1 and 2 for Decrypt?"))

            if TypeOfCipher == 1 :  
                TypeOfEncrypt = int(input("Press 1. Polyalphabatic, 2. Transposition, 3. Bit-wise")
                if TypeOfEncrypt == 1 : 
                    print (TypeOfEncrypt)

        return None

1 个答案:

答案 0 :(得分:1)

我认为此错误是由于缺少)

您的代码应如下所示:

def main():

        FileToRead =  input("Select the File in Directory :")


        File = open("C:\\Users\\User\\Documents\\" + FileToRead + ".txt", 'r')

        Data = File.read()

        File.close()

        print (Data)

        if Data != None :
            TypeOfCipher = int(input("For Encrypt Press 1 and 2 for Decrypt?"))

            if TypeOfCipher == 1 :  
                TypeOfEncrypt = int(input("Press 1. Polyalphabatic, 2. Transposition, 3. Bit-wise")) # extra )
                if TypeOfEncrypt == 1 : 
                    print (TypeOfEncrypt)

        return None