代码拉取完成,页面将自动刷新
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(os.path.join(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"{os.path.join(root, file)} {line_num + 1}: this line is TOO LONG({len(line)}/120)")
context += line + '\n'
context = context[:-1]
while context.endswith('\n'):
context = context[:-1]
if not context.endswith('\n'):
context += '\n'
with open(f"{root}/{file}", "w", encoding="utf-8") as f:
f.write(context)
if __name__ == "__main__":
main()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。