str.startswith() not working as I intended

前端 未结 5 1195
滥情空心
滥情空心 2021-01-29 11:13

I can\'t see why this won\'t work. I am performing lstrip() on the string being passed to the function, and trying to see if it starts with \"\"\". For some reason, it gets caug

5条回答
  •  盖世英雄少女心
    2021-01-29 11:34

    You haven't provided and exit path from the recursive loop. A return statement should do the trick.

        (...)
        while True:
            if line.rstrip().endswith('"""'):
                line = infile.readline()
                return find_comment(infile, line)
            else:
                line = infile.readline()
    

提交回复
热议问题