1. 增加了请求框架
2. 增加了删除虚拟环境的脚本
This commit is contained in:
39
request/fix_newlines.py
Normal file
39
request/fix_newlines.py
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/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}")
|
||||
Reference in New Issue
Block a user