File size: 411 Bytes
6a5bb7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import ast, sys

files = [
    'E:/DairyGoat/Scripts/train_baseline.py',
]
for path in files:
    try:
        with open(path, encoding='utf-8') as f:
            source = f.read()
        ast.parse(source)
        print(f'{path} 语法正确')
    except FileNotFoundError:
        print(f'{path} 不存在,跳过')
    except SyntaxError as e:
        print(f'{path} 语法错误: {e}')
        sys.exit(1)