import re with open('douyin_fudai.py', 'r', encoding='utf-8') as f: content = f.read() lines = content.split('\n') # 查找所有可能的缩进问题模式 problems = [] for i in range(len(lines)-1): line = lines[i] next_line = lines[i+1] if i+1 < len(lines) else '' stripped = line.rstrip() next_stripped = next_line.rstrip() if not stripped or not next_stripped: continue # 当前行缩进 indent = len(line) - len(line.lstrip()) next_indent = len(next_line) - len(next_line.lstrip()) # 如果当前行是控制语句(以冒号结尾) if stripped.endswith(':'): next_content = next_stripped.lstrip() # 下一行不是 else/elif/except/finally,且缩进不正确 if next_content and not next_content.startswith(('else:', 'elif ', 'except', 'finally:')): if next_indent <= indent: problems.append((i+2, indent, next_indent, stripped[-80:], next_stripped[:80])) print(f'Found {len(problems)} potential indentation problems:') for p in problems[:50]: print(f'Line {p[0]}: expected indent > {p[1]}, got {p[2]}') print(f' After: ...{p[3]}') print(f' Line: {p[4]}') print()