Files
YG_FT_Platform/request/fix_newlines.py
DESKTOP-72TV0V4\caoxiaozhu bda8f13446 1. 增加了请求框架
2. 增加了删除虚拟环境的脚本
2026-01-12 14:20:44 +08:00

40 lines
1.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
修复文件的换行符,将 Windows 风格的 \r\n 转换为 Unix 风格的 \n
用法python fix_newlines.py <file1> <file2> ...
"""
import sys
import os
def fix_newlines(file_path):
"""修复文件的换行符"""
print(f"修复文件: {file_path}")
try:
# 读取文件内容
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
# 写入文件,使用 Unix 风格的换行符
with open(file_path, 'w', encoding='utf-8', newline='\n') as f:
f.write(content)
print(f"✅ 修复成功: {file_path}")
return True
except Exception as e:
print(f"❌ 修复失败: {file_path}, 错误: {e}")
return False
if __name__ == "__main__":
if len(sys.argv) < 2:
print("用法: python fix_newlines.py <file1> <file2> ...")
sys.exit(1)
# 修复所有指定的文件
for file_path in sys.argv[1:]:
if os.path.exists(file_path):
fix_newlines(file_path)
else:
print(f"❌ 文件不存在: {file_path}")