#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 检查截图文件状态 """ import os import sys def check_screenshot_file(): pic_path = r"C:\Users\12742\Desktop\douyin_guaji-main\pic\screenshot.png" if os.path.exists(pic_path): size = os.path.getsize(pic_path) print(f"screenshot.png exists, size: {size} bytes") if size == 0: print("WARNING: Screenshot file is empty!") elif size < 1024: print("WARNING: Screenshot file is too small (possibly corrupted)") else: print("Screenshot file size looks normal") # Try to read first 4 bytes to check PNG header try: with open(pic_path, 'rb') as f: header = f.read(4) if header == b'\x89PNG': print("PNG file format is correct") else: print(f"WARNING: File format issue, header: {header}") except Exception as e: print(f"ERROR reading file: {e}") else: print("screenshot.png does not exist") # Check tmp file tmp_path = pic_path + ".tmp" if os.path.exists(tmp_path): tmp_size = os.path.getsize(tmp_path) print(f"screenshot.png.tmp exists, size: {tmp_size} bytes") else: print("screenshot.png.tmp does not exist") if __name__ == "__main__": check_screenshot_file()