加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
format_coding_style.py 823 Bytes
一键复制 编辑 原始数据 按行查看 历史
import os
def main():
for root, dirs, files in os.walk("physicsLab"):
try:
dirs.remove("__pycache__")
except ValueError:
pass
for file in files:
with open(f"{root}/{file}", encoding="utf-8") as f:
lines = f.read().splitlines()
context: str = ""
for line_num, line in enumerate(lines):
while line.endswith(' '):
line = line[:-1]
if len(line) > 120:
print(f"{root}\{file} {line_num + 1}: this line is TOO LONG({len(line)}/120)")
context += line + '\n'
context = context[:-1]
with open(f"{root}/{file}", "w", encoding="utf-8") as f:
f.write(context)
if __name__ == "__main__":
main()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化