【python】关于if..else..continue的问题

def main():
    while True:
        menu()
        choice=int(input('请选择:'))
        if choice in [0,1,2,3,4,5,6,7]:    #注意!!!!
            if choice==0:
                answer=input('请问您是否要退出系统?y/n')
                if answer=='y' or answer=='Y':
                    print('感谢您的使用~')
                    break
                else:
                    continue
            elif choice==1:
                luru()
            elif choice==2:
                chazhao()
            elif choice==3:
                shanchu()
            elif choice==4:
                xiugai()
            elif choice==5:
                paiming()
            elif choice==6:
                tongjirenshu()
            elif choice==7:
                suoyouxinxi()
        else:
            #我这里没有写continue,为什么输入9也会执行continue呢?
            print('您的输入有误,请重新选择')

main()

输入9为什么不会报错?
上面虽然有else: continue,但并没有与第一个if对齐呀。
是Pycharm智能修改错误吗?像下面的

print(os.path.basename('D:\PyCharm\Learn\learn\learn.py'))

这个不用转义字符也可以正常运行。
 

 

我明白了,是while本身就有循环的作用,执行else块后,又一次进入了循环。因此,不需要continue了。

输入9,就不在第5行代码里面,就会直接走else,输出print那一句话