随笔 - 25  文章 - 0  评论 - 0  阅读 - 65930

python函数说明内容格式错误

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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

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

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

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

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

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

posted on   那个踩到香蕉皮的妖怪  阅读(495)  评论(0编辑  收藏  举报

点击右上角即可分享
微信分享提示