print("Hello world! - python.jsrun.net .")import argparse
def replace_punctuation(input_file, output_file):
try:
with open(input_file, 'r', encoding='utf-8') as f:
content = f.read()
new_content = content.replace('《', '<').replace('》', '>')
with open(output_file, 'w', encoding='utf-8') as f:
f.write(new_content)
print(f"替换完成!结果已保存至 {output_file}")
except FileNotFoundError:
print(f"错误:输入文件 {input_file} 不存在")
except Exception as e:
print(f"发生未知错误:{str(e)}")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='文档标点替换工具 - 将中文书名号《》替换为英文尖括号<>')
parser.add_argument('input', help='输入文件路径')
parser.add_argument('output', help='输出文件路径')
args = parser.parse_args()
replace_punctuation(args.input, args.output)