python函数说明内容格式错误

def levlTwo(levloneList,levlOneNum):
     """
    入参levloneList 一级城市列表
    入参levlOneNum 用户选择的城市序号
    出参levlTwoList 返回二级城市列表
    """
    if int(levlOneNum) <= len(levloneList)-1:
        print("""--------------------------------
    欢迎进入城市查询系统!
    ------------------------------------
    %s市下有以下区域:
    b 返回
    q 退出"""%(levloneList[int(levlOneNum)]))
        levlTwoInfo = cityData[levloneList[int(levlOneNum)]]
        levlTwoList = []
        for x in levlTwoInfo:
            levlTwoList.append(x)
        for i in levlTwoList:
            print(levlTwoList.index(i),i )
        return levlTwoList

 函数中""" .... """ 并没有按照格式化对其导致运行时程序报错

  File "D:/新建文件夹/DAY1/ThreeDirectory/ThreeDirectory.py", line 36
    if int(levlOneNum) <= len(levloneList)-1:
                                            ^
IndentationError: unindent does not match any outer indentation level

  将函数的注释内容格式对齐即不报错了

def levlTwo(levloneList,levlOneNum):
    """
    入参levloneList 一级城市列表
    入参levlOneNum 用户选择的城市序号
    出参levlTwoList 返回二级城市列表
    """

  看来python对于格式的要求是十分严格的

posted on 2016-04-10 23:20  那个踩到香蕉皮的妖怪  阅读(493)  评论(0编辑  收藏  举报