HW2

Recording
Slides
Type
HW
探究了餐厅评分的例子,作业本身还算比较简单,基本没有用到什么稀奇的函数。但是学到了代码规范,尤其是 groupby 相关的代码。
 
给每个测试文件前面添加一行
test_dir = Path("./tests/") for file in test_dir.rglob ( '*.py' ): with open(file, "r+") as t: lines = t.readlines() if lines[0] != "OK_FORMAT = 1\n": lines.insert(0, "OK_FORMAT = 1" + "\n") s = ''.join(lines) with open(file, 'w') as f: f.write(s)